In a formal situation, you would just ask, 'Would you excuse me, please?", without saying where you are going, even though everybody knows.
If you don't know where the restroom is, then simply ask "Where is the restroom?" They'll know what you need it for without saying.
I very seldom hear "I have to pee.", even among friends. It would only be used if it were practically an emergency that you go. Usually it would be "I have to go."
If you're feeling a bit more informal, the normal expression would be "I have to whiz" or "I have to take a whiz." or "I have to take a tinkle."