Yes, one of the signs of urinary tract infections is pain burning while passing urine.
If you have a urinary tract infection it does burn when you pee, I'm not sure however if the same goes for when you poop. If it hurts when you poo maybe it's because you need to drink more water and eat more fruit (fiber).