In the beginning of his life Ajamila was certainly very pure, and he associated with devotees and brahmanas; because of that pious activity, even though he was fallen, he was inspired to name his son Narayana. Certainly this was due to good counsel given from within by the Supreme Personality of Godhead. As the Lord says in Bhagavad-gita (15.15), sarvasya caham hrdi sannivisto mattah smrtir jnanam apohanam ca: “I am seated in everyone’s heart, and from Me come remembrance, knowledge and forgetfulness.” The Lord, who is situated in everyone’s heart, is so kind that if one has ever rendered service to Him, the Lord never forgets him. Thus the Lord, from within, gave Ajamila the opportunity to name his youngest son Narayana so that in affection he would constantly call “Narayana! Narayana!” and thus be saved from the most fearful and dangerous condition at the time of his death. Such is the mercy of Krishna. Guru-Krishna-prasade paya bhakti-lata-bija: by the mercy of the guru and Krishna, one receives the seed of bhakti. This association saves a devotee from the greatest fear. In our Krishna consciousness movement we therefore change a devotee’s name to a form that reminds him of Vishnu. If at the time of death the devotee can remember his own name, such as Krishnadasa or Govinda dasa, he can be saved from the greatest danger. Therefore the change of names at the time of initiation is essential. The Krishna consciousness movement is so meticulous that it gives one a good opportunity to remember Krishna somehow or other.
Source: A.C. Bhaktivedanta Swami Prabhupada (2014 edition), “Srimad Bhagavatam”, Sixth Canto, Chapter 02 – Text 32