Heartburn occurs when stomach acid backs up into the tube that carries food from your mouth to your stomach (esophagus). Typically, when food is swallowed, a band of muscle around the bottom of the esophagus (lower esophageal sphincter) relaxes to allow food and liquid to flow down into the stomach.