Unintentional upshifting is a fairly common complaint, particularly with strong riders who use fairly flexible frames. The typical symptom is that the bike shifts up to the next smaller rear sprocket when you stand and pedal hard.
The first thing most people check is the shift lever, and back in the days of friction shift levers that required periodic re-adjustment, this was often the cause. Most friction shift levers have a screw or wingnut to regulate the friction. If this screw becomes too loose, automatic upshifting will result. Sometimes, however, the problem is not due to insufficient friction, and tightening the lever won't cure it.
With the advent of indexed shifting, the problem is much less prevalent than it used to be, but it can also occur with index systems. When it does, you don't even have a friction regulation screw to adjust.
Autoshifting may also result from a loose derailer attachment bolt, a damaged cable or an indexing mismatch between shifter and cassette.
An internal-gear hub also may autoshift, or slip out of gear. Cable adjustment is especially critical on newer hubs with many speeds and a short cable pull between each speed and the next. The Shimano Alfine 11-speed hub will malfunction if the cable adjustment is off by as little as 1.5 mm. [Thanks go to reader Dale Christensen for this information!]. An indicator spindle of an older hub can unscrew itself from the cable, too -- see advice on adjustment.
The usual cause of the problem, though, believe it or not, is the cable guide that the derailer or hub shifter cable uses to get around the bottom bracket. As you pedal the bike, the frame flexes from side to side. This causes the gear cable to get tighter and looser with every other pedal stroke.
If the bottom-bracket cable guide has too much friction, it can act as a one-way clutch, pulling the cable down from the lever, but not allowing it to retract on the opposite pedal stroke. In many cases, greasing the cable guide is all that is required.
In one particularly bad case, that of a large, strong racer with an old steel bike, I had to use more heroic measures. I installed a Sturmey-Archer pulley that clamped onto the bottom of the seat tube in place of the original cable guide. This eliminated the problem.