The middle ear is an air filled cavity behind the eardrum. The Eustachian tube is a small tube that connects the middle ear to the back of your throat. The purpose of the Eustachian tube is to keep the pressure in the middle ear equal to the pressure of the "outside world." Sometimes when you swallow, you hear a popping or crackling sound. Those are the sounds of bubbles of air moving into the middle ear through the Eustachian tube. If tube becomes blocked, or if it does not function properly, then pain can develop.
Pain while flying is often called aero-otitis, and it usually occurs as the plane descends for landing because you are moving from lower to higher pressure in the airplane cabin. If the Eustachian tube does not work properly, the cabin pressure will remain much greater than the middle ear pressure and the eardrum is pushed inward, sometimes causing extreme discomfort. If the pressure in the middle ear does not equalize to the outside pressure, fluid from the middle ear membranes may accumulate in the middle ear because of the vacuum. If you have trouble equalizing pressure when flying, consult with your primary care physician. Oral decongestants and nasal sprays are available that can often help the Eustachian tube function better when flying.