Convention has it used after a match whether good or bad (Most often in computer games). By respect.
Usually the first one who writes gg in and ending battle is the signal he/she admits defeat. Commentators will usually yell ''GEE GEE!'' with great enthusiasm.
A sarcastic way from saying Good Game( or gg). First used in Minecraft, by a unknown user, then started spreading to other games such as Dota 2, and League of Legends.