"Is it ok...?" depends on opinion and interpretation (it's certainly not illegal), but if you ask, "What are the downsides of...", that's easier to answer. I'll address that if that's ok. :)
It is very unwise to do as that teacher has done for several reasons, the primary one being exactly the situation your child has experienced.
It is pitting one child against their classmates, setting the child up for potential retaliation of some kind.
It is placing a child in a position of authority (without actual authority) over children of the same age.
It is a lazy way for the teacher to "keep order" in the classroom while they are absent.
It can be perceived as favoritism (teacher's pet) by the other students, fostering some resentment.
It reflects badly on the (inappropriately?) authoritarian teacher.
It sets kids up for punishment instead of praise.
A teacher is responsible for the social well-being of all the children under their care while they are under their care. That teacher did the opposite. A wiser move on the teacher's part would be to give the kids something to work on while they are out: a puzzle, a math problem, a maze, a reading assignment to be discussed on their return, etc.
It is also unreasonable for the teacher to expect nine year old children to remain completely quiet while unsupervised. IMO, a teacher can do the above, or can allow quiet discussion (whispering only, without leaving their seats) and praise them if they choose to obey, or praise them for completing a task assigned, etc.
If the teacher insists on absolute silence when they are absent, they should arrange for another adult to supervise the classroom while they are out.