We investigate the effect of surface acoustic waves on the atomic-like optical emission from defect centers in hexagonal boron nitride layers deposited on the surface of a LiNbO$_3$ substrate. The dynamic strain field of the surface acoustic waves modulates the emission lines resulting in intensity variations as large as 50% and oscillations of the emission energy with an amplitude of almost 1 meV. From a systematic study of the dependence of the modulation on the acoustic wave power, we determine a hydrostatic deformation potential for defect centers in this two-dimensional material of about 40 meV/%. Furthermore, we show that the dynamic piezoelectric field of the acoustic wave could contribute to the stabilization of the optical properties of these centers. Our results show that surface acoustic waves are a powerful tool to modulate and control the electronic states of two-dimensional materials.