When we are sad, why do we feel pain in our stomachs? I thought everything is in the brain.

Why do we feel pain in our stomachs when we are sad?
I certainly wouldn't say "everything is in the brain"; even the central nervous system is defined more broadly than that (to include the spinal cord)...and then there's everything else in the peripheral nervous system to consider...

I also wouldn't say that feeling pain in one's stomach when sad is normal (you didn't say this either, but it's implied by your phrasing, so I think you might've assumed it), but this and the many other varieties of somatization aren't necessarily abnormal either, in as much as it may occur for most people in some way at some point in life (an intuitive guess informed by personal experience; don't quote me on this). From Wikipedia: "Somatization is a tendency to experience and communicate psychological distress in the form of somatic symptoms," which includes bodily pain of pretty much any variety. Note that this definition raises some interesting questions, e.g.:


How do you know if it&#39;s psychosomatic or not?
Can psychosomatic reactions be completely unconcious?


Setting these aside and assuming sadness is your original source of stomach discomfort, there are a number of ways this could occur, and the stress of strong negative emotion (which includes sadness) could exacerbate it. Stress in general can cause ulcers (e.g., stress from head injury; Li et al., 2010). Here's a good (and very long) section from The Cortisol Connection (Talbott &amp; Talbott, 2007) [bolding added]:


  The phenomenon of stress-induced ulcers and other digestive problems has been documented in the medical literature for more than fifty years. From a physiological point of view, we know quite clearly that any stressful event will cause digestion to cease. Blood flow is diverted from the digestive organs to the heart and muscles, secretion of saliva and digestive enzymes is slowed, and intestinal contractions and absorption of nutrients stop. This rapid shutdown of the digestive process makes perfect sense, because from the standpoint of long-term survival it is more important to get away from the dangerous stressor (the lion) than to fully digest all your food...However...even while stress hormones are signaling the body to shut down digestion, these same hormones, when kept elevated for more than a few minutes, are telling us to eat...
  
  Medical evidence shows quite clearly that ulcers of the stomach (gastric ulcers) and intestine (duodenal ulcers) are much more common in people who are anxious, depressed, or under chronic or repeated stress. In the face of these conditions, which are all also examples of chronic stressors, many of the digestive actions are curtailed, and the body also backs off from its production of other protective measures—such as the mucus that lines the stomach, and the bicarbonate that counteracts the highly acidic gastric juices...The problems start to occur when a person experiences the repeated cycles of high stress followed by low/normal stress...This sets up the digestive system for total confusion. Most of the time the body won't be able to secrete enough digestive enzymes to properly digest food (producing nausea, constipation, gas, and bloating). During the "lucky" times when a body can secrete enough digestive enzymes to properly break down food, the protective mechanisms are far from fully operational—which puts the person at risk for damage to her gastrointestinal tract (because the food enzymes digest the gut's lining in addition to digesting the food). This scenario says a lot about why several bouts of intense stress are known to cause more ulcers than a longer continuous period of heightened stress.
  
  To compound the problem, other factors, such as immune-system function and the body's control of inflammation and wound healing, come into play. It is well described in the medical literature that both repeated periods of acute stress and continuous periods of chronic stress are associated with suppressed immune-system activity. This has a direct bearing on ulcer development, because less immune-system activity means more growth and higher activity of a bacterium called Helicobacter pylori, which infects the stomach and causes ulcers in 80 percent of the people infected with it. Compounding the tissue damage caused by the accelerated growth of H. pylori is a suppression of the body's ability to heal that tissue damage because of an inhibition in prostaglandin synthesis. Prostaglandins are typically produced in response to tissue damage, where they help reduce inflammation and accelerate healing. During times of stress, however, the synthesis of prostaglandins is curtailed, which suggests that stress not only increases the rate at which ulcers may form, but also slows the rate at which they are repaired.
  
  Aside from ulcers, the most common stress-related gut disease may be irritable bowel syndrome (IBS). Most of us will experience some degree of IBS during our lifetime. The name "IBS" is really a catchall for a variety of intestinal disorders...The majority of the gastrointestinal conditions falling under the IBS umbrella are either caused by or exacerbated by periods of heightened stress. Irish researchers have solidified the link between stress, inflammation, and gastrointestinal diseases such as IBS through a series of experiments involving 151 subjects that showed IBS to be clearly exacerbated by stressful psychological events, with cortisol and inflammatory cytokines such as IL-6 and IL-8 elevated in all forms of IBS...
  
  So, again, we have bad news about stress and cortisol for an important bodily system. Stress leads to poor digestion, ulcerated stomachs, and inflamed intestines—not a pretty picture. These effects tend to result in poor dietary choices, suboptimal nutritional status, and a drop in energy levels and overall feelings of well-being. Getting stress and cortisol levels under control can help to reverse these problems.


Pardon the wall of text; I could hardly shorten it further without cutting out directly relevant material or supportive explanation of the responsible anatomical mechanisms. Anyway, given that sadness (a form of stress) can cause our stomachs to go haywire when it's intense or chronic enough, haywire stomachs can then reduce energy and well-being, which forms a wicked little feedback loop between emotional and gastrointestinal distress. Feeling stomach pain can also cause one to clench the abdominal muscles, leading to cramping, which itself also leads back to pain and stress, so that's two feedback loops! Severe and chronic stress can also lead to rumination among those without better coping mechanisms, which is another cognitive-emotional feedback loop unto itself: the more you worry about your stress (both emotional and physiological) is the more you have to worry about!

Given at least these three, distinct, vicious cycles, it's not hard to imagine how a person can spiral out of control and into true disorder. Somatization disorder (SSD) is one such possibility; pain disorder is another. Both involve physical pain that is largely, sometimes completely caused by psychological stress, and are sometimes comorbid with mood disorders, among others. SSD is also sometimes comorbid with IBS. 

Extreme cases might best relate to the sentiment expressed in your question, but that doesn't mean your case is extreme or even abnormal necessarily. If you or anyone else is concerned that you might have a disorder such as pain disorder, SSD, IBS, or if you're in any way concerned about how depressed you feel, I'd encourage you to talk to a counselor or therapist (some help is even available for free), seek diagnosis only from licensed professionals, and focus on what you can do about it instead of how bad it might be right now. Most psychological problems can at least be improved through patience, persistence, and positivity, so don't worry about labeling your problem or yourself; focus on finding and pursuing improvements and hope.

Here are some ideas that may help break feedback loops that exacerbate psychogenic stomach distress:


Dietary choices that ease digestion (including anti-inflammatory, low acidity foods)
Nutritional improvement (e.g., vitamins &amp; minerals for stress response, probiotics for digestion)
Stress reduction (as via lifestyle choices, R &amp; R, social support, counseling, etc.)
Cognitive behavioral therapy and biofeedback
Limited, careful, pharmacist-supervised medication of some physical and neurochemical problems
General mindfulness of automatic negative thoughts and unconscious muscle tension
Exercise, recreation, and positivity—generally spending more time looking on the bright side of life!


References

Li, Z. M., Wang, L. X., Jiang, L. C., Zhu, J. X., Geng, F. Y., &amp; Qiang, F. (2009). Relationship between plasma cortisol levels and stress ulcer following acute and severe head injury. Medical Principles and Practice, 19(1), 17-21.

Talbott, S. M., &amp; Talbott, S. (2007). The cortisol connection: Why stress makes you fat and ruins your health - And what you can do about it (pp. 120-122). Hunter House.