Heartburn is caused by the acids in the stomach flowing up the esophagus. The foods and liquids that are eaten pass through the esophagus into the stomach where further digestion takes place. The acids in the stomach are very strong and aid in breaking down the substances eaten into simpler compounds that can be absorbed in the other organs of the digestive system.
The lower esophageal sphincter is a valve that opens for very short durations of time either to allow food to flow in or gases created in the stomach to be released when we belch.
If the valve does not close completely or stays open for a duration of time that is longer than necessary the acids in the stomach can flow up the esophagus. This can burn the delicate lining of the esophagus and if it reaches the throat can cause damage to it. The immediate effect of the action of the acid on the esophagus or in the throat is a sharp burning sensation and pain.