Optimal control problems in transport dynamics