The person who is told off is "the whipping boy".
A:"Did you tell the boss off?"
B:"No, but John was with the boss when the boss made the mistake, so I told John off when he was with the boss."
A:"Ah! So you used John as the boss's whipping boy."
B:"Exactly - I think the boss got the message."