when to play h3/h6

So, in terms of white playing h3, sometimes g4 is the only useful square for black's c8 bishop, and so white will play it preemptively.
Sometimes white wants to play Be3 or otherwise doesn't want to deal with black playing knight on f6 to g4.
Sometimes as white your bishop is on, e.g. f4 and you've played e3 so black can sometimes play Nh5 and "win" a bishop for a knight (not always a big deal). But when it is a big deal, white often plays h3 to give the bishop a retreat square.
Sometimes GMs are booked up to move 143 (lol) so they use it as a high level waiting move.
---
That said, two important points:
1) Usually developing a minor piece is more useful. So unless you're playing it for a specific reason (and the reason is a good one) then you're just wasting time in the opening.
2) Especially if you've castled on that side and the opponent hasn't castled yet, it can give them an attack (with your pawn sticking out there like that, pawn breaks as well as sacrifices can more easily open your king).
When in doubt... develop a piece and get castled instead. h3/h6 is the sort of move that, when it looks good and you're not sure, you want to calculate hard to find a way NOT to play it.