State-dependent optical tweezers can be used to trap a pair of molecules with a separation much smaller than the wavelength of the trapping light, greatly enhancing the dipole-dipole interaction between them. Here we describe a general approach to producing these state-dependent potentials using the tensor part of the ac Stark shift and show how it can be used to carry out two-qubit gates between pairs of molecules. The method is applicable to broad classes of molecules including bialkali molecules produced by atom association and those amenable to direct laser cooling.