The only time a -> ~a is when a is false. When a is false, a can imply anything. This is known as the principle of explosion.
https://en.wikipedia.org/wiki/Principle_of_explosion
(Latin: ex falso [sequitur] quodlibet, 'from falsehood, anything [follows]'; or ex contradictione [sequitur] quodlibet, 'from contradiction, anything [follows]')
As conifold pointed out, this can come up in an argument from contradiction.
edit. My answer seems... controversial, but there's another answer on this stackexchange making the same connection that seems more well-received - perhaps it's explained better there: https://philosophy.stackexchange.com/a/10528/49717