The pain you experience during take-off is due to air pressure changes inside the cabin, as the airplane suddenly changes altitude. Inside the middle ear is an air pocket, which has to expand as pressure changes around it. To normalize the ear drum, air must pass through the Eustachian tube, a tiny 35 mm passageway linking to the pharynx to the middle ear that is normally closed. When the tube adapts normally, you hear the familiar slight "pop" that happens inside the ear when a plane takes off. When it doesn't pop, you can experience intense pain. Sinus congestion or scar tissue from past ear infections can worsen the condition.
If you have congestion due to allergies or a cold, you will want to address that before stepping onto the plane. Take a nasal decongestant spray a few hours before flying, or try taking Sudafed--or a generic form--half an hour before flying.
You can find special ear plugs in airport shops knows as "EarPlanes," which help with ear pain. As of 2009, the product cost about $6 and is designed to keep the pressure balanced inside the ears by blocking airflow to the eardrum. In order to work, put them in before taking off, and make sure to not take them out until you land.
Yawning, or simulated yawning, helps to open up the passageway. You can also exhale sharply through your nostrils while pinching your nose and closing your mouth. Swallowing periodically can also be effective. Many travelers find chewing on gum helps facilitate this.