Shower valve: connecting 1/2 inch pipe to 1 inch shower valve (threaded)
That looks like one side of a union. The threads on the union nut engage with threads on the valve body to make a flat metal-to-metal seal.  Alternatively a special seal, now missing, might have fit in a groove and pipe dope was used to try to make it seal.

Pipe dope is to be used to seal threads. A union seals with two clean flat surfaces clamped together by threads, or with a special seal (not pipe dope). You might get it to seal by cleaning down to bare metal without gouging the surface, but it could be that a seal is needed.

EDIT

If you reinstall this part or a new one you will have to use a slip coupling, e.g., a Shark Bite 1/2" "slip" coupling. That way you won't have to use a torch inside the wall.