The cruising velocity of animals, or robotic vehicles, that use flapping wings or fins to propel themselves is not constant, but oscillates around a mean value with an amplitude usually much smaller than the mean, and a frequency that typically doubles the flapping frequency. The force and moment that an oscillating stream exerts on a two-dimensional pitching and heaving airfoil is obtained using the vortical impulse theory in the linear potential flow limit. The new terms appearing in relation to previous related works on the subject are discussed. The theoretical results obtained here are also compared with existing computational and experimental data on flapping foils immersed in a periodic stream.