Until painful. If you are having pain you need to be seen. Frequent voiding may help, but when you feel you need to void, and you can't, you have waited long enough.
Don't wait. True urinary retention is inability to urinate and is an emercency requiring catheterization unless due to fecal impaction. Don't wait, it will not go away by itself. In case you mean mean incomplete bladder emptying or partial retention, which is not an emergency, call and make an appointment with your local urologist. Good luck.