http://revach.net/article.php?id=3753

Section: Halacha   Category: Tshuvos
Rav Menashe Klein - Naming A Baby After Someone Who Recently Died
Rav Menashe Klein (Mishneh Halachos 4:152) was asked if it is permissible to name a baby after someone who died but was not yet buried.  Although reluctant to answer a question not found in Shas or Poskim, he said that people are noheg to do so.

However he did see in the Zohar that it may not be effective.  The Zohar says that until a person is buried, his Neshama cannot enter another a person in the form of a Gilgul.  Since one of the reasons we name after a niftar is to enable the neshama to enter the child as a gilgul, it would be pointless until after the burial.  This is also the opinion of the Shu"t Tshuras Shai and the Recanti.

What if the child was born while the person was still alive but the name will be given after the burial?  In this case he says that even though the child already received a neshama at birth, nevertheless the neshama of the gilgul can enter at the time the name is given.  We see this from Pinchas who received the neshamos of Nadav and Avihu even though he was alive at the time of their death.  

This is the same logic as giving a sick person a new name.  The hope is that the neshama of a person with the same name will enter into him and extend his life.  For this reason changing the name of a Choleh should be handled only by someone who is well versed in these matters.

Important Note: We try to convey the Tshuva to the best of our ability. We admit that our understanding may not be accurate. One should learn the tshuva to verify the accuracy of our interpretation.  Please also understand that this Tshuva may not be the final word on this topic. One should consult a Rav before drawing any conclusions.