A quantum theory of spin dynamics in the rare-earth orthoferrites excited by terahertz laser pulses is developed. The study demonstrates that dynamic magnetic configurations, triggered by a light pulse, exhibit stability even after the excitation source is ceased. The magnitude of post-excitation oscillations is linked to the ratio between the frequency of rare-earth ion excitations and the frequency of the external source. According to the analysis presented, dynamic response is significantly amplified when the system is exposed to ultrashort terahertz pulses. The physical characteristics of the oscillations emerging after the pulse are determined, and the factors governing their amplitude and phase are identified. The response signal is found to be dependent on the initial part of the pulse, specifically the half-period of the ultrashort light wave, while the subsequent part of the pulse contributes minimally to post-pulse magnetization dynamics. The findings highlight that in DyFeO3, terahertz dynamics primarily result from the influence of the magnetic field of the light, leading to excitations of electrons from the ground state to low-lying electronic levels of Dy3+ions. Additionally, the dynamic magnetoelectric effect excited by the electric field of the pulse is explored, revealing the emergence of odd magnetic modes.