"To turn the table on someone" means to retaliate.
Historical note: the original meaning of the phrase was completely different.
In the old-fashioned formal dinner parties of years ago (before my time!) it was customary to sit people around the table alternating men and women. In such a situation, every woman could have a conversation with either the man on her right or the man on her left. In order for everyone to have a conversational partner, everyone needed to do the same thing. But for variety, everyone wanted to speak to both neighbors during the meal. So, everyone followed the example set by the hostess. If the hostess began by talking to the gentleman on her right, so would every other lady. The hostess "turned the table" by ending the conservation with the gentleman on her right, then turning to talk to the gentleman on her left. Everyone else at the table did the same thing. Everyone at the table turned.