Most workers have a right to go to the bathroom. OSHA requires 6 toilets (also called “water closets”) for the first 150 workers and one more toilet for each additional 40 workers. OSHA also says that you have to be able to USE those toilets when you need to – there shouldn't be rules which stop you from going when you need to or long lines during break times.
The rule which covers bathrooms at work is: 29CFR Toilet facilities.1910.141(c)(1).
If you don't have enough bathrooms or your boss doesn't let you use the bathroom, you can file a complaint with OSHA. If you decide, OSHA will not tell your boss who filed the complaint.