You could have a test done to see if there is any bacteria in your sperm.
Do they know what bacteria caused your prostatitis?
In the meantime, you could always use a condom for sex until you are sure, but chances are, after 40 days of antibiotics, there isn't any bacteria.
You've been fully treated for the UTI, correct? Taken antibiotics and the infection/uti is gone? Then there would be no chance of bacteria. You were on antibiotics to clear bacteria and I'd assume it worked or you yourself would still be having symptoms of the uti. While there is potential for some contamination of sperm, I'd personally not worry about this in your situation since you've been on antibiotics. Normally you'd see sperm being less mobile and less in quantity or number. Here's an article looking at contamination of sperm. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2649329/ But remember, you took a hefty dose of antibiotics so that would essentially rid your body of bacteria. Talk to your doctor to confirm.