Heartburn is caused when stomach acid enters the esophagus. Typically, the LES [Lower Esophageal Sphincter] opens like a one-way valve that allows food into the stomach. However, at times the LES relaxes and allows stomach juices to flow back into the esophagus, exposing it to the harsh acids in your stomach. Physicians refer to this as gastroesophageal reflux.
For the occasional heartburn, you can try antacids or H2 blockers. Antacids neutralize the acid in your stomach, but they only provide immediate, temporary relief. H2 blockers reduce acid production, and relief can last for 12 hours. While they can both work for occasional heartburn, if you have frequent heartburn, you may find that the relief does not last long enough. Proton Pump Inhibitors (like AcipHex) can provide relief with a single pill. You can also make a few lifestyle changes to ease your symptoms and reduce the chances of heartburn.