Lady Aisha (may Allah be pleased with her) narrates that the Messenger of Allah (peace be upon him) used to remember Allah Almighty at all times. These are the words of Abu Kurayb’s narration.
It was because mentioning Allah Almighty with purity is more virtuous, not because mentioning Allah Almighty without purity is not permissible. Because the Prophet Muhammad (peace be upon him) used to mention Allah Almighty at all times.
Hadith Referenceصحيح ابن خزيمه / جماع أبواب فضول التطهير والاستحباب من غير إيجاب / 207