Unfortunately the answer is "from experience." Everything comes with trade offs and knowing when to use subqueries versus temp tables is more around the context of the problem and the experience of doing things the wrong way.
I'd recommend toy problems or building little tools in a dev env to get that kind of experience.