Is it always a good idea to trade a bishop for a knight if the enemy has castled and is forced to disrupt his castle's pawn structure? I want to thank you beforehand for taking your time to read and (hopefully) answer this. My question is a bit ambiguous, so I'll give an example. Let's say I'm playing white, the enemy has castled king-side so his king is on g8, with his rook on f8, and his knight is on f6. Also, he's got his three castle pawns at their original positions. My dark-square bishop is fianchettoed and I can thus trade it for his f6 knight. If he can only take the bishop with the g7 pawn, opening up his king, when is it a good idea to trade (i. e. what other factors affect if it is a good idea or not)?

[FEN "5rk1/5ppp/5n2/8/8/8/1B3PPP/5RK1 w - - 0 1"]
As always with such questions, the correct answer is "It depends on the position!". 

For example if your opponent doesn't have an e-pawn, you will create isolated doubled pawns, which are generally quite weak. But in a 4 vs 3 rook endgame, with all pawns on the kingside this structure is actually better for black than f7-g7-h7 because it is harder for white to create a passed pawn.

Taking gxf6 will often weaken the black king, but only if you are actually able to attack him. If you have all your pieces on the queenside he might just play Kh8, Rg8 and start an attack on your king!

So, this is a weakening of his structure, but you have to be able to take advantage of it. Otherwise a bishop might just be more useful than a knight.