Recent advances in the understanding of spin orbital effects in ultrathin magnetic heterostructures have opened new paradigms to control magnetic moments electrically. The Dzyaloshinskii-Moriya interaction (DMI) is said to play a key role in forming a Néel-type domain wall that can be driven by the spin Hall torque. Here we show that the strength and sign of the DMI can be changed by modifying the adjacent heavy-metal underlayer (X) in perpendicularly magnetized X/CoFeB/MgO heterostructures. The sense of rotation of a domain wall spiral is reversed when the underlayer is changed from Hf, Ta to W and the strength of DMI varies as the filling of 5d orbitals, or the electronegativity, of the heavy-metal layer changes. The DMI can even be tuned by adding nitrogen to the underlayer, thus allowing interface engineering of the magnetic texture in ultrathin magnetic heterostructures.