It's usually spoken casually when someone is proven wrong, but only when the person is defeated, or surprised. In the case of being defeated, "I'll be damned" shows that you accepted the loss.
You can think of it like two people betting on who will win a race. The loser, once the race is over, would probably say this due to losing his bet, or because he was surprised he lost.
You would never say it, however, if you were expecting to be proven wrong.