You use the expression ‘A Taste of Your Own Medicine’ to indicate that someone is
sampling the same unpleasantness they’ve been dishing out to others.
Example of use: “I don’t feel at all sorry that people are calling you names. You’re getting a taste of your own medicine.”
The origin of the phrase ‘a taste of your own medicine’ comes from Aesop’s famous story about a swindler who sells fake medicine, claiming that it can cure anything. When he falls ill, people give him his own medicine, which he knows will not work.