I would imagine there's a considerable backstory here!
It sounds as if the teacher had been trying to get the class quiet for some time and that was her final word on the matter, only for Master Annoying to try to be the class joker.
Non-teachers won't understand, however hard they try, the difficulties and subtleties of classroom management. (Anecdote to follow...optional).
One little jokey remark from student can set the whole class off, especially is the child still persists in coming back with another quip. And another 10 mins is wasted.
Anecdote: this concerns an older child (14). He was the son of a friend who had no experience of teaching. Her son was clever and a bit of a handful. He had his phone under the table and the very young female teacher asked 'Josh (nc obvs) what's that in your hand?' Josh replied 'My penis, Miss'. He was bollocked, bollocked again and made to do a Saturday detention in school uniform. This was about 15 years ago, btw.
My friend was indignant. Her son was just making a joke! Hadn't the teacher got a sense of humour? Josh normally got on well with her, so why did she make such a big deal of it? I had to explain that on many levels he was completely out of order. It was an insolent reply, not a joke. Even if it was a joke, it was out of place in the classroom setting - it's not a one-to-one social event, the teacher has her whole class to manage and can't make exceptions to behaviour rules. But most glaringly of all, it was a sexual remark to a young female teacher...would he have done that to a man? Absolutely out of order, and he needed to learn fast that it wasn't acceptable behaviour.
Moral of anecdote: the rules of the classroom are necessarily different to those of home or a night out with your mates.