Yep, first step is cleaning then replacing the thermocouple. Try shining it up with some fine grit sand paper and position it just a little closer to the flame. If that does not work pick up a new one.
Clean it completely with de greaser spray or whatever. Clean and inspect with a magnifying glass or zoom camera on phone for imperfections or breaks. Try reinstalling and see if it did the job. If not replace.
I think you have a weak pilot and the updraft established by the hot fireplace basically blows it out after the main flame goes out.
I would start by pulling the pilot assembly out of the fireplace, then disassemble the pilot and clean with water and a little brush if you have something like that.
There's no reason to get the thermopile wet, just wipe it off.
There's a good chance the pilot orifice is partially blocked, if you have some 18 gauge stranded wire, you might be able to poke a single strand through the tiny hole. It's usually easier to just replace them. There should be a number on it, buy the same size.
NinjaCoder t1_j6nj21g wrote
What does the pilot flame look like?