Used as an interjection in the same way as "Crap!" or "Damn!" and even "God!"
Some people, such as myself, find it more humorous to use the word "balls" in place of harsher words.
A few examples:
1) Getting killed in Counter-Strike.
2) Upon discovering your expulsion from college.
3) Upon discovering that you have testicular cancer.
(okay maybe #3 could've been left out.)
2) Oh, Balls!
3) OH MY BALLS!!