Welcome to HCM.Masturbation
is better avoided, when you have urinary tract infection
. However there is no hard and fast rule that masturbation should never be done during UTI. If you feel like masturbating and if you are confortable with it, you might as well masturbate.
Primarily the attempt should be made to find out the source of infection, and that sorce should be avoided.
Wish you all the best.