  Damping of magnetic fields via ambipolar diffusion and decay of
magnetohydrodynamical (MHD) turbulence in the post decoupling era heats the
intergalactic medium (IGM). Delayed recombination of hydrogen atoms in the IGM
yields an optical depth to scattering of the cosmic microwave background (CMB).
The optical depth generated at $z\gg 10$ does not affect the "reionization
bump" of the CMB polarization power spectrum at low multipoles, but affects the
temperature and polarization power spectra at high multipoles. Writing the
present-day energy density of fields smoothed over the damping scale at the
decoupling epoch as $\rho_{B,0}=B_{0}^2/2$, we constrain $B_0$ as a function of
the spectral index, $n_B$. Using the Planck 2013 likelihood code that uses the
Planck temperature and lensing data together with the WMAP 9-year polarization
data, we find the 95% upper bounds of $B_0<0.63$, 0.39, and 0.18~nG for
$n_B=-2.9$, $-2.5$, and $-1.5$, respectively. For these spectral indices, the
optical depth is dominated by dissipation of the decaying MHD turbulence that
occurs shortly after the decoupling epoch. Our limits are stronger than the
previous limits ignoring the effects of the fields on ionization history.
Inverse Compton scattering of CMB photons off electrons in the heated IGM
distorts the thermal spectrum of CMB. Our limits on $B_0$ imply that the
$y$-type distortion from dissipation of fields in the post decoupling era
should be smaller than $10^{-9}$, $4\times10^{-9}$, and $10^{-9}$,
respectively.
