We describe an accurate and efficient extension of Chawla and Voth's [J. Chem. Phys. 108, 4697 (1998)] plane-wave based algorithm for calculating exchange energies, exchange energy densities, and exchange energy gradients with respect to wave-function parameters in systems of electrons subject to periodic boundary conditions. The theory and numerical results show that the computational effort scales almost linearly with the number of plane waves and quadratically with the number of k vectors. To obtain high accuracy with relatively few k vectors, we use an adaptation of Gygi and Baldereschi's [Phys. Rev. B 34, 4405 (1986)] method for reducing Brillouin-zone integration errors.