Sometimes people with social anxiety have problems described by you. People with social anxiety disorder become extremely anxious in social situations, have difficultly eating in public or urinating in public toilet. In case your problem is diagnosed as due to the same, the it can be treated with counselling &/or medication.
Another reason why that could happen is feeling unhygienic about urinating in public places, with fear of contracting infections.
Next Steps
Please visit a psychiatrist who needs to evaluate you in detail to find the exact cause & accordingly suggest treatment.