Quantum optimal control theory (QOCT) provides the necessary tools to theoretically design driving fields capable of controlling a quantum system towards a given state or along a prescribed path in Hilbert space. This theory must be complemented with a suitable model for describing the dynamics of the quantum system. Here, we are concerned with many electron systems (atoms, molecules, quantum dots, etc.) irradiated with laser pulses. The full solution of the many-electron Schrödinger equation is not feasible in general, and therefore, if we aim for an ab initio description, a suitable choice is the time-dependent density-functional theory (TDDFT). In this Letter, we establish the equations that combine TDDFT with QOCT and demonstrate their numerical feasibility.