Brahmanas, Kshatriya, and Vaishyas all undergo Upanayanam as early as 7 years of age. Having done Upanayanam, they become Brahmacharis.
One important vow of Brahmacharya is maintenance of celibacy, meaning no intentional emission of semen (masturbation or sex).
Here is what the Manusmriti says:
Persons learned in the Veda and knowing the law declare that for the
twice-born person keeping up his vows, the intentional emission of
semen means a ‘transgression of the vow.’—(120)
This vow is very important to be maintained, as stated in the next verse:
The spiritual power of the Religious Student (Brahmachari), who has
become ‘immoral,’ (Avakirnin) ‘goes away into the Maruts, Indra,
Bṛhaspati and Agni.—(121)
In fact, that's the reason given in the Apastamba sutras as to why no Rishis are born in kali yuga:
The word 'austerity' (must be understood to apply) to (the observance
of) the rules (of studentship).
If they are transgressed, study drives out the knowledge of the Veda
acquired already, from the (offender) and from his children.
Besides he will go to hell, and his life will be shortened.
On account of that (transgression of the rules of studentship) no
Rishis are born amongst the men of later ages [Kali yuga].
So, only an intentional emission of semen constitutes a break in the vow of Brahmacharya.
However, the Apastamba Dharma Sutras say this:
strībhir yāvad artha saṃbhāṣī || 16 ||
- Let him talk with women as much [only] as is necessary.
So, I would say that if you have sexual relations or interaction with a woman, but don't intentionally emit your semen, then you broke the rules of Brahmacharya, although you didn't technically violate the vow of Brahmacharya.