There are a few problems that can cause that.
#1. The pilot pressure may be too low. This can be caused by improper pilot setting or a dirty pilot orifice.
# 2 Too low main gas pressure. Too low main burner pressure can cause the main burners to draw the pilot fuel away from the pilot, and the thermocouple cools as a result. The thermocouple is made of two different types of metal-when heated they create a DC currnet. This current is usually around 100MV so it does not take much pilot loss to cool the thermocouple and have it drop out the pilot.
In either case I recomend that you have a professional clean it or set the pilot and main gas pressure. If the heater is over 5 -7 years old save your money and replace it all together.