  Quantum optimal control represents a powerful technique to enhance the
performance of quantum experiments by engineering the controllable parameters
of the Hamiltonian. However, the computational overhead for the necessary
optimization of these control parameters drastically increases as their number
grows. We devise a novel variant of a gradient-free optimal-control method by
introducing the idea of phase-modulated driving fields, which allows us to find
optimal control fields efficiently. We numerically evaluate its performance and
demonstrate the advantages over standard Fourier-basis methods in controlling
an ensemble of two-level systems showing an inhomogeneous broadening. The
control fields optimized with the phase-modulated method provide an increased
robustness against such ensemble inhomogeneities as well as control-field
fluctuations and environmental noise, with one order of magnitude less of
average search time. Robustness enhancement of single quantum gates is also
achieved by the phase-modulated method. Under environmental noise, an XY-8
sequence constituted by optimized gates prolongs the coherence time by $50\%$
compared with standard rectangular pulses in our numerical simulations, showing
the application potential of our phase-modulated method in improving the
precision of signal detection in the field of quantum sensing.
