So glad to find this discussion.
When I presented to my doc with a dull ache in my left (and sometimes right) testicle, stomach and anal discomfort and anxiety, he went straight to IBS and treated it with antibiotics, spasmeds etc. Worked well - for a while (like travis111). But here's the kicker - I developed this IB (I leave out the "syndrome" as I understand proper IBS is a condition that requires a longer presence to be clinically diagnosed) within 2 weeks of a particularly extreme and ongoing stressful situation, the details of which are not relevant. The point is that even short term anxiety induced IB and/or other gastrointestinal problems can, and apparently regularly does, cause testicular discomfort exactly as you experience, and apparently also referred penile pain of which I also have a light bout of. I can also identify with spasman's "trapped gas" explanation in some instances.
Pain caused by IB often leads to more anxiety, which causes more IB and pain which... and so on. Imagine someone who's anxiety is std related, albeit unfounded, and who then experiences testicular pain for the first time because they stressed themselves into IBS! It even happens that IB driven anxiety and/or primary anxiety causes some people to release small amounts of urine which, if it stays around the penis/scrotum long enough may cause further burning symptoms. Man, that is the mother of all negative feedback loops! (This probably explains to a lot of the extreme std-fear-related posts on the web where people just keep getting symptoms, despite testing fine.)
Now - I understand that 95% + of serotonin produced in the body is metabolized/produced(?) in the gastrointestinal tract. The Dr. who previously treated me for reflux is studying this link in more detail. (This is apparently also why many people on antidepressants are somewhat prone to diarrhoea as the regular intestinal function is stimulated by serotonin). It is not difficult to see how this all fits together for my type of problem.
My conscious mind knows (strongly suspects) what is going on, but my subconscious is not buying in. So I have to cheat my body into believing it's fine (which is actually is) so that it can believe it too.
No more antibiotics and antispasmodics for me. In short, I'm now treating my IB, reflux AND TESTICLE PAIN with an antidepressant (which is of the type that is also indicated for anxiety and general body pain or "Fibromyalgia") - I bet it is going to work like a charm.
Your cause and solution may be different, but give this some thought.
Cheers and good luck to all