We study the quantum beats in the polarization of the photon echo from donor-bound exciton ensembles in semiconductor quantum wells. To induce these quantum beats, a sequence composed of a circularly polarized and a linearly polarized picosecond laser pulse in combination with an external transverse magnetic field is used. This results in an oscillatory behavior of the photon echo amplitude, detected in the $sigma^+$ and $sigma^-$ circular polarizations, occurring with opposite phases relative to each other. The beating frequency is the sum of the Larmor frequencies of the resident electron and the heavy hole when the second pulse is polarized along the magnetic field. The beating frequency is, on the other hand, the difference of these Larmor frequencies when the second pulse is polarized orthogonal to the magnetic field. The measurement of both beating frequencies serves as a method to determine precisely the in-plane hole $g$ factor, including its sign. We apply this technique to observe the quantum beats in the polarization of the photon echo from the donor-bound excitons in a 20-nm-thick CdTe/Cd$_{0.76}$Mg$_{0.24}$Te quantum well. From these quantum beats we obtain the in-plane heavy hole $g$ factor $g_h=-0.143pm0.005$.