Most commonly I have found that to be the result of a weak, dirty, pilot. When the main shuts off there is a strong draft and it blows out the pilot.
This is more of a problem recently because for energy efficiency they are using smaller, weaker pilot that are more sensitive to this. Some brands even had a recall and they sent out a new pilot that had a bigger hood to protect against blowing out. But sometimes cleaning the pilot orifice will solve it though.
I take a piece of braided wire stripped back some and use it like a miniature wire brush to clean it. The hole in the orifice is smaller than a pin hole.
The second, less common problem is that sometimes the main burner gets warped and the main flame encompasses the pilot. So while burning the pilot is out but the main flame is keeping the thermocouple warm then when the main goes out the pilot is out. That is usually solved by checking to see if the main burner is level and correcting it if is it not.
Good Luck.
And PS, if you watch it burning and are fooling with it, on and off, don't put your face directly in front of it, look from the side and back some because if it misfires you don't want to lose your eyebrows. I have seen more than one tech who had their eyebrows "trimmed" and have come close to it myself.