A finite element heterogeneous multiscale method is proposed for the wave equation with highly oscillatory coefficients. It is based on a finite element discretization of an effective wave equation at the macro scale, whose a priori unknown effective coefficients are computed on sampling domains at the micro scale within each macro finite element. Hence the computational work involved is independent of the highly heterogeneous nature of the medium at the smallest scale. Optimal error estimates in the energy norm and the L-2 norm and convergence to the homogenized solution are proved, when both the macro and the micro scales are refined simultaneously. Numerical experiments corroborate the theoretical convergence rates and illustrate the behavior of the numerical method for periodic and heterogeneous media.