The word, ‘Khuda Haafiz’ is a Du’aa literally meaning ‘May Allah protect’.
There is no prohibition in mentioning ‘Khuda Haafiz’ before departing from
one another. However, Rasulullah (Sallallaahu Alayhi Wasallam) taught us the
following Du’aa before departing, ‘Astawdi-u Allaaha Deenakum, Wa
Amaanatikum Wa khawaatim a’amaalikum’ (Trans: I entrust Allah your
steadfastness in religion and Deeni actions till death).
It was also a habit of two Sahaaba (Radhiallaahu Anhum) to recite Surah
al-Asr to one another before departing in order to remind one another the
importance of time.
and Allah Ta’ala Knows Best
Mufti Ebrahim Desai