Easy fix. Mine did that a few years ago. It's probably a bad thermocoupler. You can get a replacement for about 10 bucks and it should solve the problem...it's a bolt-on part and shouldn't take long to install.
edit: You can also test that theory by getting some steel wool or emory cloth and cleaning the thermocoupler on your heater. If it starts to run better for a few days then the problem comes back, it needs replacement. If it just needs a good cleaning then you'll be good to go. After cleaning mine multiple times over the span of a month, I just replaced it and got it over with.