Yes, you can use "leave the class" since you both know what you're taking about.
The definite article the is the most frequent word in English.
We use the definite article in front of a noun when we believe the hearer/reader knows exactly what we are referring to.
• because there is only one in that place or in those surroundings
You can say:
“Will you please permit me to leave class and go to the bathroom?”
In this case you don't specify the class. Maybe you're talking about the class you're attending at the moment, maybe you're asking if you could leave any class in general when you have to go to the bathroom.
“Will you please permit me to leave the class and go to the bathroom?”
In this case you're talking about a given class, the one that you're attending at the moment or the one that was referenced before in the context, so it's known which class you're talking about, you're not talking in general.