Humanae Vitae is explicit in its teaching against artificial birth control, and yes, the context is marriage. But Humanae Vitae itself answers the question:
Hence, one who reflects well must also recognize that a reciprocal act of love that jeopardizes the responsibility to transmit life that God the Creator, according to particular laws, inserted therein, is in contradiction with the design constitutive of marriage, and the will of the Author or life. To use this divine gift destroying, even if only partially, its meaning and its purpose is to contradict the nature both of man and of woman and of their intimate relationship, and therefore it is to contradict also the plan of God. (HV 13)
These two sentences teach that anything that destroys the meaning of the “reciprocal act of love”—in this case contraception—is contrary to God. The Catechism calls these actions “intrinsically evil” (CCC 2370), meaning that it is evil in and of itself: It is always objectively evil, regardless of the context (within marriage or outside of it) in which it is carried out.
The Church also teaches that sex outside of marriage is contrary to the will of God and destroys the true purpose of the act (cf. CCC 2353). Therefore, if one uses birth control while engaging in sex outside of marriage, he is compounding one sin with another.