Occupation where the person receives the punishment for upper class kids
I’ve read it somewhere but I don’t remember it, it was apparently very popular during medieval times especially for the wealthy. The people that are taking the punishment are usually kids.
What was this occupation called?
It wasn't an occupation so much as slavery/oppression, but the term is whipping boy.
A whipping boy was a boy educated alongside a prince (or boy monarch) in early modern Europe, who received corporal punishment for the prince's transgressions in his presence. The prince was not punished himself because his royal status exceeded that of his tutor; seeing a friend punished would provide an equivalent motivation not to repeat the offence.
[Wikipedia]
Apart from historic reference, the term is now only encountered in the metaphorical usage (anyone blamed / punished for the misdemeanours or incompetence of others).