If the pilot light on your water heater keeps going out, you may have a bad thermocouple. A thermocouple is essentially a small generator that produces a magnetic current that opens the magnetic gas valve situated in the control unit on the front of the tank. The generator or the wiring can fail so that the thermocouple cannot sense the heat from the pilot. This will cause the pilot light to shut off repeatedly. The best solution is to replace the thermocouple. If you choose to attempt this by yourself, you should read the instructions that come with the thermocouple very carefully and follow all recommended safety precautions.