The law is currently unclear on this, but you do have a right to take a break for 20 minutes if you work more than six hours a day, and therefore do have a clear right to use the toilet during this time, or during a lunch break.
If you have a medical condition which means you have to take a toilet break at other times your employer would not be able to deny you a break.
The TUC is pressing for legal change to give people the right to use the toilet at other times. Find out more in the TUC's Give us a (Loo!) break guide.