…nor make a bald spot…for the deceased. (Deuteronomy 14:1)
Just as we may not cut ourselves as a sign of mourning, we may not tear our hair out in grief. While our verse only specifies “between your eyes” (meaning the place of tefillin), we see from Leviticus 21:5, which addresses the kohanim, that tearing one’s hair out applies any place on the head. While one should not pull his hair out under any circumstances, one would not be subject to a court-imposed penalty unless he did it in the place of the tefillin (i.e., “between the eyes”) and in grief for the dead.
The reason for this prohibition is the same as for the one against cutting: we are obligated to protect the bodies that God has given us and ripping our hair out fails in that responsibility. When done in mourning, it shows an inability to accept God’s judgment.
This mitzvah applies in all times and places. It is discussed in the Talmud in tractates of Makkos (20a-b) and Kiddushin (35b-36a). It is codified in the Shulchan Aruch in Yoreh Deah 180. This mitzvah is #171 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos and #164 of the 194 negative mitzvos that can be observed today as listed in the Sefer HaMitzvos HaKatzar of the Chofetz Chaim.