Generally speaking, that is up to the faculty (the teacher of that particular class).
If the campus administration comes up with rules about what is on-topic, you will see protests about academic freedom.
On the other hand, if a teacher abuses that academic freedom (and gratuitous discussion of religion or politics in class would be such an abuse), he will quick learn that academic freedom does not amount to academic license.
In practice, most faculty are pretty responsible, and do want to discuss the topics of their own discipline without being distracted into religion and politics.