I've heard claims such as
People who have sex at least 2 times a week between the age of 20 and 30 are less likely to get cancer later.
People who have too much sex are more likely to get cancer.
Are these based on scientific results?
There have been multiple studies that have shown that frequent ejaculation in men reduces the risk of prostate cancer.
Two such studies are cited in this article from the Harvard Medical School:
29,342 men between the ages of 46 and 81 reported their average number of ejaculations per month in young adulthood (ages 20–29), in mid-life (ages 40–49), and in the most recent year. Ejaculations included sexual intercourse, nocturnal emissions, and masturbation. ... The scientists found that men who ejaculated 21 or more times a month enjoyed a 33% lower risk of prostate cancer compared with men who reported four to seven ejaculations a month throughout their lifetimes.
An Australian study of 2,338 men came to a similar conclusion. In all, men who averaged 4.6 to seven ejaculations a week were 36% less likely to be diagnosed with prostate cancer before the age of 70 than men who ejaculated less than 2.3 times a week on average.
So, yes, at least one form of cancer (prostate cancer) is less likely for men who ejaculate more frequently.
But before you rush out to bed as many women as possible in an attempt to stave off prostate cancer, bear in mind that other studies have found that the incidence of prostate cancer was positively correlated with the number of female sexual partners. From Sexual Factors and the Risk of Prostate Cancer:
Risk estimates increased directly with the lifetime number of female sexual partners but not with male partners.
Other types of HPV are called high-risk types because they are strongly linked to cancers, including cancer of the cervix, vulva, and vagina in women, penile cancer in men, and cancers of the anus, mouth, and throat in both men and women. The high-risk types include HPV 16, HPV 18, HPV 31, HPV 33, and HPV 45, as well as some others. There might be no visible signs of infection with a high-risk HPV until pre-cancerous changes or cancer develops.
Doctors believe that a woman must be infected with HPV in order to develop cervical cancer. Although this can mean infection with any of the high-risk types, about two-thirds of all cervical cancers are caused by HPV 16 and 18.