user-1: It's Black's move in the diagram.
In a recent correspondence game I managed to win an exchange at a cost of weakening my kingside a little bit. In the diagrammed position the g-pawn is missing and the White queen is lurking around. You also see the dark-squared bishop as a potentially aggressive resource for white. Seeing all of this coming my question was:
1. What are the right squares for the king?
2. Should I push my h-pawn to h6? (I will probably have to play e6 to protect f5, so, Bg5-f6 is a threat.
3. Do I put my rook on g-file? In the actual game I did, but that ended up smothering my king in the corner and for a long time to come gave tactical traps to my opponent.
Is there a general guide for how to defend such weakened structures? Like how to cover up for a missing h-pawn, or g-pawn, or f-pawn?
Thanks for your time.

[fen "5rk1/2q1ppbp/p1p5/2N1Pp2/8/2PP2Q1/P1P3PP/1rB2RK1 b - - 0 1"]

1...Qxe5 2. Qxe5 Bxe5 3. Nd7 Bxc3 4. Nxf8 Bd4+ 5. Kh1 Be3


FYI: I can't take on e5 due to the exchange followed by knight fork :(

user12449: 
[fen "5rk1/2q1ppbp/p1p5/2N1Pp2/8/2PP2Q1/P1P3PP/1rB2RK1 b - - 0 1"]

1...Qxe5 2. Qxe5 Bxe5 3. Nd7 Bxc3 4. Nxf8 Bd4+ 5. Kh1 Be3


Due to the pin on the 1st rank, black wins a piece with a won game.  Although the end game is difficult, it's better than passively hiding.

Since we're close to an end game, the right place for the king is in the center.
If more pieces were on the board, I would go with a plan of Kh8; e6; h6; Kh7.  This would limit the white dark square bishop.
The rook on the g-file doesn't accomplish anything.  No other piece can assist in any attack.  The only active place would be on b1 via b8, after you protect against a knight fork on a6.

A general rule-of-thumb is that when under attack to return material to weaken the attacking force.  One that I use is to return material to simplify into a won end game.  That is, if I have a queen and pawn versus a rook, I exchange the queen for the rook to get a won pawn end game.
Most books are written for the fun part of chess--the attack.  However, by assessing the needs of the position, you can find defensive moves.  Here the most important element is to stop Bh6 and mate next.  Kh8 must be played; f6 looks too artificial and just kills your pawn structure.  The next step would be to both protect f5 and fix the weakness on e5 (the weakness is not the pawn but that it blocks the bishop), but white's first move is most likely d4 to protect e5, which makes a new threat on a6--it was protected earlier by a queen fork.  (BTW, we'd like to keep the pin on e5 until we can fix it with e6, so protecting the a-pawn would be done by a5, even though Qa5 seems to win an pawn.  Finally, h6 and Kh7, if you can manage these move, would restrict white's bishop further.
This seems like a long post, but I barely scratched the surface.

user15668: You forgot to say who has the move in the given position. This is always important. 
For example, here if White has the move, he can attack with 1.Bh6, and he will be up a piece. 
So we can assume that Black has the move. 
In that case he had better play 1...Kh8 to avoid White's attack with 2.Bh6. This move also frees Black's bishop, so White should probably defend the pawn with 2.d4 and Black will probably need to play 2...Rg8. This already answers a couple of your questions (the king needs to go to h8, and the rook will go to g8). 
But I leave the other points to better players...

-1: <p>It's Black's move in the diagram.</p>

<p>In a recent correspondence game I managed to win an exchange at a cost of weakening my kingside a little bit. In the diagrammed position the g-pawn is missing and the White queen is lurking around. You also see the dark-squared bishop as a potentially aggressive resource for white. Seeing all of this coming my question was:</p>

<p><strong>1. What are the right squares for the king?</strong></p>

<p><strong>2. Should I push my h-pawn to h6? (I will probably have to play e6 to protect f5, so, Bg5-f6 is a threat.</strong></p>

<p><strong>3. Do I put my rook on g-file?</strong> In the actual game I did, but that ended up smothering my king in the corner and for a long time to come gave tactical traps to my opponent.</p>

<p>Is there a general guide for how to defend such weakened structures? Like how to cover up for a missing h-pawn, or g-pawn, or f-pawn?</p>

<p>Thanks for your time.</p>

<pre><code>
[fen "5rk1/2q1ppbp/p1p5/2N1Pp2/8/2PP2Q1/P1P3PP/1rB2RK1 b - - 0 1"]

1...Qxe5 2. Qxe5 Bxe5 3. Nd7 Bxc3 4. Nxf8 Bd4+ 5. Kh1 Be3

</code></pre>

<p>FYI: I can't take on e5 due to the exchange followed by knight fork :(</p>
 12449: <pre><code>
[fen "5rk1/2q1ppbp/p1p5/2N1Pp2/8/2PP2Q1/P1P3PP/1rB2RK1 b - - 0 1"]

1...Qxe5 2. Qxe5 Bxe5 3. Nd7 Bxc3 4. Nxf8 Bd4+ 5. Kh1 Be3

</code></pre>

<p>Due to the pin on the 1st rank, black wins a piece with a won game.  Although the end game is difficult, it's better than passively hiding.</p>

<ol>
<li>Since we're close to an end game, the right place for the king is in the center.</li>
<li>If more pieces were on the board, I would go with a plan of Kh8; e6; h6; Kh7.  This would limit the white dark square bishop.</li>
<li>The rook on the g-file doesn't accomplish anything.  No other piece can assist in any attack.  The only active place would be on b1 via b8, after you protect against a knight fork on a6.</li>
</ol>

<p>A general rule-of-thumb is that when under attack to return material to weaken the attacking force.  One that I use is to return material to simplify into a won end game.  That is, if I have a queen and pawn versus a rook, I exchange the queen for the rook to get a won pawn end game.</p>

<p>Most books are written for the fun part of chess--the attack.  However, by assessing the needs of the position, you can find defensive moves.  Here the most important element is to stop Bh6 and mate next.  Kh8 must be played; f6 looks too artificial and just kills your pawn structure.  The next step would be to both protect f5 and fix the weakness on e5 (the weakness is not the pawn but that it blocks the bishop), but white's first move is most likely d4 to protect e5, which makes a new threat on a6--it was protected earlier by a queen fork.  (BTW, we'd like to keep the pin on e5 until we can fix it with e6, so protecting the a-pawn would be done by a5, even though Qa5 seems to win an pawn.  Finally, h6 and Kh7, if you can manage these move, would restrict white's bishop further.</p>

<p>This seems like a long post, but I barely scratched the surface.</p>
 15668: <p>You forgot to say who has the move in the given position. This is always important. </p>

<p>For example, here if White has the move, he can attack with 1.Bh6, and he will be up a piece. </p>

<p>So we can assume that Black has the move. </p>

<p>In that case he had better play 1...Kh8 to avoid White's attack with 2.Bh6. This move also frees Black's bishop, so White should probably defend the pawn with 2.d4 and Black will probably need to play 2...Rg8. This already answers a couple of your questions (the king needs to go to h8, and the rook will go to g8). </p>

<p>But I leave the other points to better players...</p>
