According to Amie Taylor on http://homeguides.sfgate.com/lawnmower-revs-up-down-100220.html
A lawnmower that hunts and surges may be experiencing something as simple as an airflow issue. If the air that the engine requires to run is blocked, especially sporadically, it can cause the engine to slow down. When the blockage moves or clears, the engine may suddenly rev up in response. To fix this type of problem, check the air filter to ensure that it's not clogged with dirt and debris. Check the vented gas cap as well. Both issues can cause reduced or sporadic air flow, and clearing them will fix the problem.
Spark Plug Problems
Another problem that can cause revving and dying of a lawnmower engine is a faulty or poorly adjusted spark plug. Check the spark plug to see if the wire is connected to it firmly and not wobbling about. If it is connected correctly, remove the spark plug to see if it's covered with corrosion. If so, a simple scrubbing with a wire brush can restore it to working order. If necessary, replace the spark plug with a new one. Check the spark plug gap with a spark plug gauge to ensure that it's adjusted to the proper setting recommended in your owner's manual.
A carburetor that's incorrectly adjusted is a common cause of poor engine idling that results in hunting and surging. Fortunately, most lawnmowers have two screws that allow you to adjust the carburetor yourself. One screw controls the idle speed while the other adjusts the idle mixture. Check the manual if you're unsure of the location of the idle adjustment screws. Start the mower and allow it to run for 5 minutes. Then slowly adjust the screws tighter or looser in turn until the mower runs and idles smoothly.
A particularly simple fix that can be at the bottom of many lawnmower idling problems is old or contaminated fuel. If the fuel has been left in the mower while it was stored over the winter or while the mower has remained unused, drain it and replace it with fresh fuel. If you have gas-powered blowers and trimmers that use a mixture of 2-cycle oil and gasoline, check to see that you've not placed that mixture in the lawnmower inadvertently."