  We show how dynamical decoupling (DD) and quantum error correction (QEC) can
be optimally combined in the setting of fault tolerant quantum computing. To
this end we identify the optimal generator set of DD sequences designed to
protect quantum information encoded into stabilizer subspace or subsystem
codes. This generator set, comprising the stabilizers and logical operators of
the code, minimizes a natural cost function associated with the length of DD
sequences. We prove that with the optimal generator set the restrictive
local-bath assumption used in earlier work on hybrid DD-QEC schemes, can be
significantly relaxed, thus bringing hybrid DD-QEC schemes, and their
potentially considerable advantages, closer to realization.
