MgO-based magnetic heterostructures with interfacial magnetic anisotropy has attracted increasing attention due to its application in building high-density magnetic random access memories. A large and tunable interfacial magnetic anisotropy constant (Ki) is required for high thermal stability and flexible data writability. In this study, the Ki of Fe/MgO, Fe/Pt/MgO, and Fe/Ir/MgO heterostructures with strains from -4.5% to 4.5% were calculated by ab initio electronic structure calculations. It has been found that the Fe/Pt/MgO and Fe/Ir/MgO where the Pt and Ir monolayers are inserted in the interface possess Ki of 2.415 mJ/m2 and -4.468 mJ/m2, which are much larger by several times than that (0.840 mJ/m2) of the Fe/MgO. In particular, the out-of-plane Ki from the interfacial Pt atoms in Fe/Pt/MgO is as high as 5.978 mJ/m2. The magnetic anisotropy of these structures can be significantly manipulated by strain. Combining second-order perturbation theory, the origin of these behaviors has been analyzed by layer-resolved, orbital-resolved, and k-resolved Ki. The spin-flip terms of dz2/dyz orbitals in the interfacial layer are mainly responsible for the out-of-plane Ki and its variation with strain. This work provides a useful guide for the design of high and tunable magnetic anisotropy in the MgO-based magnetic heterostructures.