Students are welcome to use magic around the school outside of class. For example, you might want to practice charms in your commonroom or test out a new spell in the gardens. The only limitations are to keep within the site rules:
Consider realism. For example, a first year would not be able to do difficult spells, and getting a spell to work perfectly usually takes plenty of practice. If a spell is dangerous, it is probably most sensible to only practice it in a classroom.
Consider effects and Godmodding: Your spell-casting will have knock-on effects, which might not be the ones your character had originally intended. If you cast a spell on another student or member of staff, it is up to them to decide what effect it has.
For example, in this post, Jade cast the spell but Jorge's author decided upon its effectiveness and the character's reaction.