Optical Control of the Resonant Dipole-Dipole Interaction between Rydberg Atoms