What kind of water heater is it? For the standard water heater with a natural draft and standing pilot..... There's a lot of possible causes, and often it's multiple issues. 1)Thermocouple issues: a)Weak thermocouple--thermocouple just puts out enough milli- voltage to hole the magnet open. When the pilot wavers, MV drops just enough to kill the pilot. 2)Weak electromagnet in the gas valve. This is the magnet that is energaized when you are lighting the pilot. When you hold the knob down and light the pilot, you are holding the magnet down until energized enough to stay open. If it's a weak magnet, the gas valve needs replaced. 3)Loose G-bushing: That's the gas valve end of the thermocouple. Check and make sure it's tight. 4)Dirty pilot: Ensure there's a sharp blue flame. A blue flame itself doesn't mean anything. The pilot orifice could be partially plugged causing a weak pilot that may not be striking the thermocouple well. When the flame kicks off, the weaker flame can dance off of away from the t-couple, causing the pilot to drop out. There's probably plenty more, but I'm going to bed and don't want to think too hard right now. Typically, the main causes are a combination of a dirty pilot along with a weak magnet or bad/weak t-couple. NOTE: Thermocouples burn out fairly quickly when the flame isn't hitting the proper area. The pilot flame should only hit the top 3/8"-1/2" of the t- couple. (hot junction).