The problem of oscillating flows inside pipes under periodic forcing of viscoelastic fluids is addressed here. Starting from the linear Oldroyd-B model, a generalized Darcy's law is obtained in frequency domain and an explicit expression for the dependence of the dynamic permeability on fluid parameters and forcing frequency is derived. Previous results in both viscoelastic and Newtonian fluids are here shown to be particular cases of our results. On the basis of our calculations, a possible explanation for the observed damping of local dynamic response as the forcing frequency increases is given. Good fitting with recent experimental studies of wave propagation in viscoelastic media is here exhibited. Sound wave propagation in viscoelastic media flowing inside straight pipes is investigated. In particular, we obtain the local dynamic response for weakly compressible flows.