It’s okay! Everyone slips up from time to time. The best thing to do if you use the wrong pronoun for someone is to say something right away, like “Sorry, I meant (insert pronoun)”.
If you realize your mistake after the fact, apologize in private and move on.
A lot of the time it can be tempting to go on and on about how bad you feel that you messed up or how hard it is for you to get it right. Please don’t! It is inappropriate and makes the person who was misgendered feel awkward and responsible for comforting you, which is absolutely not their job.
Taking an active role in your classes, you may hear one of your students using the wrong pronoun for someone. In most cases, it is appropriate to gently correct them without further embarrassing the individual who has been misgendered. This means saying something like “Alex uses the pronoun she,” and then moving on. If other students or faculty are consistently using the wrong pronouns for someone, do not ignore it! It is important to let your student know that you are their ally.
It may be appropriate to approach them and say something like “I noticed that you were getting referred to with the wrong pronoun earlier, and I know that that can be really hurtful. Would you be okay with me taking them aside and reminding them about your pronouns?” Follow up if necessary, but take your cues from the comfort level of your student. Your actions will be greatly appreciated.