A recent theoretical model developed by Imparato [Phys. Rev. E 76, 050101(R) (2007)] of the experimentally measured heat and work effects produced by the thermal fluctuations of single micron-sized polystyrene beads in stationary and moving optical traps has proved to be quite successful in rationalizing the observed experimental data. The model, based on the overdamped Brownian dynamics of a particle in a harmonic potential that moves at a constant speed under a time-dependent force, is used to obtain an approximate expression for the distribution of the heat dissipated by the particle at long times. In this paper, we generalize the above model to consider particle dynamics in the presence of colored noise, without passing to the overdamped limit, as a way of modeling experimental situations in which the fluctuations of the medium exhibit long-lived temporal correlations, of the kind characteristic of polymeric solutions, for instance, or of similar viscoelastic fluids. Although we have not been able to find an expression for the heat distribution itself, we do obtain exact expressions for its mean and variance, both for the static and for the moving trap cases. These moments are valid for arbitrary times and they also hold in the inertial regime, but they reduce exactly to the results of Imparato in appropriate limits.