Why does my hot water heater flame and pilot go out?
Pilot light thermocouple or valve controller.

Cheapest one to try first is the pilot light thermocouple. All the box stores and most hardware stores have them.