We consider the controllability problem for the continuity equation where the dynamics is governed by a driftless control-affine system. Under suitable regularity conditions, the controllability of the system is a sufficient condition for the controllability of the continuity equation by means of time-varying feedback controls. Moreover, we show that there exist controls such that the flow of the control system is the optimal transport map, for the 2-Wasserstein distance, between two given probability measures.