You should be able to take the test right away to see if whatever you were treated for was eradicated. Ask your doctor.
Your second question I am not sure what you mean. You should take prescribed antibiotics until the course of medication is gone. Then you can take the urine test right after. The bacteria the antibiotics is trying to kill will be gone at the end of the medication if the medication worked.