Śrīmad-Bhāgavatam · Text 9.6.51
Who is speaking and story frame
सङ्गं त्यजेत मिथुनव्रतीनां मुमुक्षु:
सर्वात्मना न विसृजेद् बहिरिन्द्रियाणि ।
एकश्चरन् रहसि चित्तमनन्त ईशे
युञ्जीत तद्व्रतिषु साधुषु चेत् प्रसङ्ग: ॥ ५१ ॥
saṅgaṁ tyajeta mithuna-vratīnāṁ mumukṣuḥ
sarvātmanā na visṛjed bahir-indriyāṇi
ekaś caran rahasi cittam ananta īśe
yuñjīta tad-vratiṣu sādhuṣu cet prasaṅgaḥ
A person desiring liberation from material bondage must give up the association of persons interested in sex life and should not employ his senses externally [in seeing, hearing, talking, walking and so on]. One should always stay in a secluded place, completely fixing his mind at the lotus feet of the unlimited Personality of Godhead, and if one wants any association at all, he should associate with persons similarly engaged.
Read Śrīla Prabhupāda's purport on Vedabase.io