The electro-optic effect in two-dimensional (2D) MgO nanoflakes synthesized by a microwave-assisted process is demonstrated using a designed optical fiber modulator. The guiding properties of intense core modes excited by the material cavity are modulated by the external electric field. The feasibility of 2D MgO nanoflakes as an effective electro-optic modulator and switching are experimentally verified for the first time, to the best of our knowledge. The proposed optical-fiber-based electro-optic modulator achieves a linear wavelength shift with a high sensitivity of 12.87 pm/V(77.22 nm/kV/mm, in the electric field). The results show that MgO, as a metal oxide 2D material, is a very promising material for electro-optic modulators and switching.