this happen to me before and what helps is drinking plenty of water before and after sex it sounds cheesy but it really helps
Its possible that you have a pelvic muscle injury. This is a called a trigger point. When you orgasm, the muscle contracts, causing spasms, thus causing the reffered pain to testicles and abdomin. www.penilepain.org for more info.