Srimad-Bhagavatam: Canto 11 - Chapter 1 - Verse 25
Sanskrit:
रेतो नावकिरेज्जातु ब्रह्मव्रतधर: स्वयम् ।अवकीर्णेऽवगाह्याप्सु यतासुस्त्रिपदां जपेत् ॥ २५ ॥
ITRANS:
reto nāvakirej jātubrahma-vrata-dharaḥ svayamavakīrṇe ’vagāhyāpsuyatāsus tri-padāṁ japet
Translation:
One observing the vow of celibate brahmacārī life should never pass semen. If the semen by chance spills out by itself, the brahmacārī should immediately take bath in water, control his breath by prāṇāyāma and chant the Gāyatrī mantra.