All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
Ma‘qil ibn Yasaar narrated that the Prophet, sallallaahu ‘alayhi wa sallam, said: “It is better for any of you to be pierced with an iron needle in his head than to touch a woman who is unlawful to him.” [Al-Qurtubi and others; Al-Albaani: Saheeh]
Unlawful women here mean those who are neither your wives nor your Mahram women due to either kinship or foster relations. One's Mahram women, however, are not meant, as the questioner mistakenly understood.
Allaah Knows best.