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 Neel-type domain wall that can be driven by the spin Hall torque, a torque resulting from the spin current generated in a neighboring non-magnetic layer via the spin Hall effect. 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 heterstructures. Albeit the same spin Hall angle, a domain wall moves along or against the electron flow depending on the underlayer. We find that the sense of rotation of a domain wall spiral11 is reversed when the underlayer is changed from Hf to W and the strength of DMI varies as the number of 5d electrons 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.