I most cases, yes, I would say so. However, if the bishop that is the same color of that flight square and the queens are traded off the board, then as long as your king can escape somewhere else or you can pick off the pawn, you'll be fine.
castling
I don’t understand the question, but I won’t recommended castling for both sides, because black’s king is wide open, and the h3 square is weak, so white might have to castle queenside
oops I messed up the board. That black pawn on h7 should be on h3. Here's the correct board. Should I castle kingside as white? Or is that pawn on h3 going to cause trouble?

I most cases, yes, I would say so. However, if the bishop that is the same color of that flight square and the queens are traded off the board, then as long as your king can escape somewhere else or you can pick off the pawn, you'll be fine.
thanks. I castled before trading but didn't get into trouble in this game. I'll keep the trades in mind next time.
oops I messed up the board. That black pawn on h7 should be on h3. Here's the correct board. Should I castle kingside as white? Or is that pawn on h3 going to cause trouble?
Might not take that long for black to attack the knight.

I just pressed the analyse button, and it said the top move was O-O
Engines show the best moves based on if you play all the best moves after it. For a human playing chess, they are most likely going to play moves based the fact that humans have a different mindset than an engine, and creativity is more likely to prevail.
I got into this position as white. I was reluctant to castle king side because of black's pawn sitting on h3 (though I did it a couple of moves later). Is castling when a pawn attacks the only flight square asking for trouble?