This is not from diet or anything related to that, don't listen to these guys. I used to get that too back when I was younger, but I found out a trick to avoid it. Basically, if you come and then try to pee even a half hour or an hour later, it's going to hurt because your penis isn't ready to switch gears yet, and you're going to get that burning pain. this can also be because there are dried bits of semen still left in your urethra, and when that mixes with the urine, bad things happen. So the answer?
Always pee before you ejaculate. If you ever feel like peeing while you're masturbating, just do it, it doesn't matter if you have an erection. You need to do it before you ejaculate or else it's going to be burny time. If you don't feel like peeing at all, go ahead and finish your business, but as long as you wait a few hours afterwards to pee, you should be fine. (but again, don't hold it. Just make sure you pee before you ejaculate.)
Hope that helps.