Which one wins?
I had 77 in my hand.
He had J8 in his hand.
Community Cards on table:
8 8 7 2 2
So who wins here?
hero 77 villain J8
Let's break it down
At this point you are only losing to
88 and 87
As Daniel said the over-pair is not a good thing for you as yes you made a boat but you are exposed to bigger boat to an 8 and any other pair including the board
A boat would protect you from a straight or flush but right now there is only 2 to the straight and you mention nothing about a flush draw
You can only improve with the case 7
At this point you are likely ahead.
In a full house, 888xx beats 777xx. That is, the higher set beats the lower without concern for what the pair is. The cards in the pair are only important if both players have the same set, such as player A's pocket being 8 2 and player B's pocket being 8 7. This would give player A 88822, and B 88877.
A full house consists of a 'three of a kind' and a 'two of a kind' (='pair'). The one with the highest 'three of a kind' would have the highest full house. An example: Consider you have A2 and the other player has KQ. The board is: AA2KK. That would make a full house for you: AAA22 and your enemy as well: KKKAA. Still your full house is better and will win.
On your example you got unlucky since your enemy needed the remaining 8 or a J or any pair on the board. The latter happened.