The ability to electrically write magnetic bits is highly desirable for future magnetic memories and spintronic devices, though fully deterministic, reversible, and nonvolatile switching of magnetic moments by electric field remains elusive despite extensive research. In this work, we develop a concept to electrically switch magnetization via polarization modulated oxygen vacancies, and we demonstrate the idea in a multiferroic epitaxial heterostructure of BaTiO/FeO fabricated by pulsed laser deposition. The piezoelectricity and ferroelectricity of BaTiO have been confirmed by macro- and microscale measurements, for which FeO serves as the top electrode for switching the polarization. X-ray absorption spectroscopy and X-ray magnetic circular dichroism spectra indicate a mixture of Fe and Fe at O sites and Fe at T sites in FeO, while the room-temperature magnetic domains of FeO are revealed by microscopic magnetic force microscopy measurements. It is demonstrated that the magnetic domains of FeO can be switched by not only magnetic fields but also electric fields in a deterministic, reversible, and nonvolatile manner, wherein polarization reversal by electric field modulates the oxygen vacancy distribution in FeO, and thus its magnetic state, making it attractive for electrically written magnetic memories.