John: In most cases it is caused by a failure of the thermocouple (sometimes called a safety element). It is the little thing on the end of the tiny tube that screws into the operating valve.
The easiest way to replace it is to remove the entire burner assembly from the bottom of the heater. Simply shut off the gas to the heater, and then disconnect the thermocouple tube from the operating valve....then disconnect the pilot gas supply from the operating valve...then disconnect the main burner gas supply tube from the operating valve...carefully pull the main burner out of the heater and replace the thermocouple ( it will be obvious to you on what must be done) most thermocouples come with instruction on proper installation. It is essential that the pilot flame come into contact with the tip of the replacement thermocouple if it is to work properly. Reassemble in reverse order...turn gas back on and check for leaks before proceeding, this can be done with a soap solution brushed on all fittings. Once it has been determined that there are no gas leaks, follow the lighting instructions for the heater. BE SURE TO CHECK FOR ANY GAS LEAKS BEFORE LIGHTING THE HEATER...Lots of luck Bud.