The Eustachian tubes are tiny tubes that run from the middle ear to the back of the throat. The primary function of these tubes is to make sure the pressure in the middle ear is the same as outside the ear. A child's Eustachian tubes are very small and cannot generally handle the rapid changes in pressure that are experienced on airplanes, causing extreme pain.
You can help prevent your child's ears from popping or decrease the pressure by giving your child a drink during takeoff and landing. Having something to drink requires swallowing, which can help equalize the pressure in the ears and prevent pain. If your child is old enough, give him gum or a hard candy to suck on, as that also encourages swallowing.
Ear pain and pressure from flying should go away as soon as the cabin pressure regulates. If your child continues to complain of ear pain long after landing, visit a doctor. It is common for children to develop ear infections after flying.