As I understand it, they were discussing in class freedom of expression and he used Charlie Hebdo (and cartoon) as one illustration among others.I'd very surprised if the state curriculum requires teachers to force such pictures onto kids in that way. I more suspect it's a choice left to the teacher as to how to present the freedom of expression argument. Suggesting the Muslim kids leave the class temporarily implies the teacher knew it was likely that strong feelings were going to be aroused.
Therefore, why not choose a different example?
If the teachers are required by the French education system to show such images, then the teacher may have been risking their job by allowing a section of the class to miss them.
Nearest I can get to in the UK is exemption for kids of religious parents, esp. Catholics, to not attend sex education classes where birth control is explained.
Given the Charlie Hebdo case has opened and, therefore, would have been in the news, this would have resonated with the pupils as ‘actualité’.
That he asked Muslim pupils to leave in case they were offended shows he was alert to sensibilities.