Modern passenger flights fly at high altitudes and despite the fact that they are pressurised; it is not possible to maintain sea level pressure during the flight. Most aircraft maintain a pressure equivalent to 6000-8000 feet above sea level. Reduction of pressure causes gases to expand, with about 20% increase in volume from sea level to 8000 feet.
The human body contains fairly large amounts of gas (including mostly air as well as gases formed in the stomach and intestines during digestion). Expansion of stomach or intestinal gas can lead to discomfort, hence it is better to avoid consuming "gas-generating" food such as beans, cabbage, carbonated drinks and beer before your flight.
The air in the middle ear cavity also expands and contracts with changes in atmospheric pressure. If the pressure is not able to be equalized, the eardrum will be distended, causing pain or temporary impairment of hearing. The middle ear pressure is normally equalized by passage of air through the Eustachian tube, which leads to the space behind the nose (nasopharynx). The tube is normally in a collapsed state but can be opened briefly by swallowing or yawning. Air in the middle ear can usually escape without problems but as the aircraft descends and the pressure is increased, the relatively lower pressure in the tube tends to keep it collapsed and result in negative pressure in the middle ear, causing discomfort or pain.
Opening of the tube can be aided by swallowing, yawning, performing the Valsalva manoeuvre (closing the mouth, holding the nostrils pinched closed and blowing to build up pressure in the mouth and nose) or the Toynbee manoeuvre (closing the mouth, holding the nostrils pinched closed and swallowing).
Sinuses are air-filled cavities in the bones of the face and skull, and are connected to the nasopharynx by small openings. If these openings are obstructed by nasal congestion, there may be considerable pain on descent. The Valsalva manoeuvre may help, but it is better not to fly with nasal congestion, head colds, hay fever or sinusitis. However, if it is essential to fly, the use of a decongestant spray before take-off and before the start of the descent may prevent the problem.
Pain on ascent may also result from the expansion of gas under a new filling, or from a dental cavity or abscess. Hence, it is better not to fly for 24 hours after a dental treatment or if you are suffering from active tooth problems.