The feeling of pain or popping in your ears during a flight is a common reaction to altitude-related changes in cabin air pressure.
The air in the middle ear passes to the Eustachian tube. This connects the nose with the middle ear and allows your body to maintain a proper balance of air pressure on both sides of the ear drum.
The National Sleep Foundation suggests frequent yawning and swallowing during takeoff and landing to help your body adjust to the changes in air pressure. You can also chew gum or suck on hard candy.
If you have a cold or sinus infection, the NSF advises taking a decongestant before flying.