Positive commandment · Mitzvat Aseh #213 of 613
To have sexual relations [only within] marriage
לבעול בקידושין
The verse · Devarim 24:1
כִּי־יִקַּח אִישׁ אִשָּׁה וּבְעָלָהּ וְהָיָה אִם־לֹא תִמְצָא־חֵן בְּעֵינָיו כִּי־מָצָא בָהּ עֶרְוַת דָּבָר וְכָתַב לָהּ סֵפֶר כְּרִיתֻת וְנָתַן בְּיָדָהּ וְשִׁלְּחָהּ מִבֵּיתוֹ
“When a man has taken a wife, and married her, and it come to pass that she find no favour in his eyes, because he has found some unseemliness in her: then let him write her a bill of divorce, and give it in her hand, and send her out of his house.”
The Rambam’s words
To have sexual relations [only within] marriage, as [Deuteronomy 24:1] states: "If a man takes a woman [as a wife]...."
לבעול בקידושין, שנאמר: "כי יקח איש אשה ובא אליה" (דברים כב, יג) וראה דברים כד, א.
Why · Sefer HaChinuch #552
To marry a woman with a marriage contract and betrothal
“It is from the roots of the commandment that we are commanded to perform an act with a woman [that] indicates the matter of their being a couple before he lays with her, and that he should not have sexual relations with her like he would have sexual relations with a prostitute — without another act between them first.”
Who & when
“And this commandment is practiced in every place and at all times.”
Where in the Mishneh Torah
Hilchot Marriage הלכות אישות