Most people don't shift enough, which leads to premature drivetrain wear, sore knees and tired riders. Think of yourself as the bike's engine. You're most efficient when pedaling at a certain rate, usually from seventy to ninety pedal revolutions per minute. To maintain this efficiency, you should shift every time you feel your pedaling rate (called cadence) slow down or speed up.
When your cadence becomes uncomfortably high, shift to a harder gear to reduce your rate and increase the power of each stroke. This often happens on a downhill. Conversely, if each stroke becomes too difficult to maintain a comfortable cadence, shift to an easier gear. You'll find yourself doing this when ascending hills. Following this rule on a rolling course, you'll shift almost constantly to maintain that steady cadence. But at ride's end, you'll feel fresh while a ride partner who shifts less will be spent.
How do you know which gear to select? Don't get confused by the many choices. The correct gear is a gear that allows you to pedal comfortably at the moment. There's no right or wrong gear, and there's no proper sequence to follow. You just shift when your body tells you it's time for a change.
Most bicycles have a right lever/shifter and a left lever/shifter for switching gears. Shifting the right lever one click makes it slightly easier or harder to pedal. Think of this lever as a way to fine tune the effort required to pedal. As you pick up speed on a slight downhill for example, you'd click the lever once or twice to shift into a better gear for the speed. Shifting the left lever makes large differences in pedal effort. Think of this lever as a way to make it considerably easier or harder to pedal. Dropping into a valley for instance, you'll want an easy gear to get back out. But, you'll probably be in a hard gear because you were just riding downhill. To make the pedaling easy immediately, shift the left lever to move the chain onto a smaller chainring, providing much easier pedaling.