The short answer is when it's adulterous.
The long answer is that there are several sins that are related to sexual immorality, both through the Bible itself and through tradition, and because idolatry, murder, and adultery are the very worst of sins in the Old Testament that you must die fighting, it's worth investigating what is and is not sexually immoral. I'll list some sexual sins here.
- Consensual sex with another's wife, according to Leviticus 20:10
- Purposefully failing to impregnate your wife, as implied by >>828970 citing Onan's punishment
- Masturbation, considered adultery with a hand to be by the Talmud
- Cuckoldry, which breaks two of the Ten Commandments
- Sodomy, which includes:
— Anal sex, per tradition, but also…
— Rape of anyone in any orifice
— Pederasty and pedophilia
— Orgies, gangbangs, threesomes, and so on
- Bestiality
- Incest, including that with in-laws and step-relatives
- Men having sex with men and women having sex with women, according to Leviticus 18:22
It's also worth noting that adultery is used by Jews to refer to all sexual immorality, whereas it's used by Christians for voluntary sex between any married person and anyone other than their spouse.