- What are the laws and customs appertaining to chanukat habayit?
- At what point, if at all, should you make a shehechiyanu; upon closing? Moving in?
- Should you make a chanukat habayit on a home that is not your main dwelling? What about a property purchased solely as an investment?
- Do you make a chanukat habayit if you purchase an apartment?
(I found all these sources in Nit'ei Gavriel on Aveilus ch. 32 footnote 1.)
A "Chanukas HaBayis" is an old custom first mentioned (though not by name) in the midrash (Tanchuma Bereishis 2 et. al.).
The Radak (Shorashim, חנך) writes that "it is a minhag to have a meal and happiness at the first eating that they eat in the new house."
The Maharshal (Yam Shel Shlomoh, Bava Kama 6:37 brought in Magen Avraham 568:8* and Shu"t Chavos Ya'ir 2), Shu"t Torah Lishmah 482, and Shu"t Divrei Malkiel 4:8 all say that a Chanukas HaBayis is a mitzvah if they say divrei Torah there. It is a mitzvah even in chutz la'aretz** (Sheiltus 1; Eretz Tzvi pt. 2, Shabbos 29).
The Shlah (Ner Mitzvah Torah Or Derech Chaim Tochachos Musar, Vayigash) explains that it is a mitzvah because you are choosing a place to learn Torah. Based on this, some authors (Shu"t Levushei Mordechai 1:101; Shu"t Ravaz 1:43; Torah Temimah, Devarim 20, note 22; Yedos Nedarim YD 246:11) mourn that the world makes the main thing secondary and the secondary thing main: The world is careful to make a meal, but not to set a place to learn Torah, which is the whole reason for the meal! However, Eretz Tzvi pt. 2 Shabbas 29 says (based on Targum Yonasan 20:5) that since you are putting a mezuzah up, which can't be done without a house, it is appropriate to have a meal even without a place to learn Torah.
None of these sources mention anything about a shehechiyanu. I personally think it is unconnected to the chanukas habayis.
*** The Mishnah Brurah (223:15) says to make shehechiyanu immediately after acquiring the house. If you buy a house as a partner, you say "HaTov VeHaMeitiv" (MB there), but as an investment or secondary home, it seems as if you make a shehechiyanu. And for an apartment, why is it different than a house? Are you talking about a rented one?
*This is the source listed in Nit'ei Gavriel, but I think it is wrong; see for yourself.
**I later found the Magen Avraham elsewhere (568:5) who disagrees
***Rabbi Ari Enkin writes in his article "Chanukat Habayit" that you should make it specifically at the chanukas habayis. He is questioned in the comments, though.