Quantum optimal control theory for solvated systems