The discomfort and little popping sounds in your ears are caused when the air pressure changes inside the plane. Small amounts of air become trapped inside your inner ear, and it can hurt.
First, try swallowing repeatedly or indulging yourself in a big yawn. If neither of those solutions work, squeeze the end of your nose closed with your fingers so that no air can pass through your nose. Then blow your nose hard just as you would if you had a cold, all the while keeping your nose blocked by pinching with your fingers. This action will force the trapped air out through your Eustachian tube and relieve the pressure immediately. You'll know you've accomplished it when you feel the difference and also hear a definite popping sound inside your ears.