All-fiber modulators and switches have drawn great interest in the photonics domain, and they are applied in viable photonic and optoelectronic devices. In this work, with the assistance of an agarose membrane, aspherical gold nanoparticles are embedded on the surface of the microfiber treated with the piranha solution. An all-fiber Mach–Zehnder interferometer was used to realize a low-cost, low-loss, and conveniently prepared all-fiber phase modulator. By taking advantage of the local surface plasmon resonance effect of gold nanoparticles embedded in the agarose membrane, under the excitation of near-infrared region light, the gold nanoparticles were excited to change the effective refractive index of one arm of the Mach–Zehnder interferometer. A maximum phase shift of ∼6π at 1550 nm was obtained from the device. In addition, an all-optical switch was achieved with a rising edge time of 47 ms and falling edge time of 14 ms. The proposed all-fiber modulator and switch based on the local surface plasmon resonance effect of gold nanoparticles embedded in agarose membrane will provide great potential in all-optical fiber systems.