Is a teacher allowed to tell a student out loud in front of the class to stop talking, to pay more attention etc. if it will cause the student embarrassment?
If the teacher has no other way of getting the student to pay attention or to stop him from hurting others by disturbing the class, it is permitted. However, if it is possible, (depending on the situation) for the teacher to do it in a way that will not embarrass the student, then it must be done in the non embarrassing way. Very often the teacher cannot stop the class in order to talk to the student, and he can’t wait until after class to get the student to stop disturbing this class.
As a side point it is possible that speaking to the student tactfully and respectfully will accomplish more in the short and long term, but this depends on the individual situation.
On the other hand a teacher or parent may not scream or punish a student or child because they are personally upset at what the child did. IN that sense a parent is no different than anyone else, since it isn’t being done with the intention to help the child, but for personal reasons.
See Makos 8a, Rambam Hilchos Sanhedrin 16-12 that a father, a teacher, or someone from Bais Din may hit a child etc. or someone else if it is for a constructive purpose. Also see the Rosh Baba Kama 3-13, and CH:M 421-13 regarding hitting someone to prevent him from sinning. Regarding embarrassing another see Baba Kama 38a, that if it couldn’t be done in another way and it is for a positive reason that it is permitted. See Chevlei Chaim siman 1 and 3.