Would you say people who bite their nails have an addiction or a habit?
I would say for some it's a habit and for others it's a compulsion (addicted to a pattern of behavior ).
What's the difference?
It's simple: a habit is a compulsion than does not interfere in a person's life in any way. If a person is biting their nails when they're nervous it's not really a problem. If a person is biting their nails so short that they end up with bloody fingers, then it's a compulsion.
Sex is an easy example - if a person enjoys frequent sex and enjoys it, stays safe and leads a productive and healthy life, you could say they have an active, healthy sexual appetite.
If, on the other hand they are having frequent sex but not enjoying it, feel ashamed and full of regret, yet can't stop themselves, when it breaks up relationships, or jeopardizes one's job or effects one's life negatively in any way, yet the person can't stop sleeping around, then it's a compulsion, or sex addiction.
If you look at the definition of addiction given by
Wikipedia, for example:
Addiction is a medical condition characterized by compulsive engagement in rewarding stimuli, despite adverse consequences.[8]
That's the crucial difference - it's not the behavior itself but the continuing behavior despite negative consequences.