When you are ahead material.
When do you trade queens
That is the million dollar question.
The short answer is you attempt to initiate a trade when it is to your advantage to do so. This might be when you are already up material and you want to trade down to a favorable endgame. You trade when you can otherwise gaine some other advantage by doing so.
It's not always done in the middlegame... at times it's done early, while still in the opening. Other times the endgame has been reached with queens still on the board.
There was a thread on this a while back, there are a few good ideas if you can wade through the spam:
http://www.chess.com/forum/view/general/when-to-exchange-queens2
Often at the beginning of the game (at least for me) each queen has a clear shot at each other once the capturing of the "sacrifice" pawns is complete. When I get the chance I usually capture the other queen, simply because it removes the option of a castle.
I assume it would be done in the midgame which I did not see a section for so I put it here, but how do you know when the right time is?