The effect of nanosecond laser pulses (λ=1064 nm) on the optical properties of onion-like carbon (OLC) prepared by high-temperature vacuum annealing of detonation nanodiamond and dispersed in N,N-dimethylformamide (DMF) was studied. It is found that the interaction between laser pulses and OLC suspension resulted in the suspension bleaching in the interaction point. The bleached fraction of the suspension was pushed out from inhomogeneous magnetic field. The observed behavior could be explained by laser-stimulated chemical reactions between OLC and DMF, which led to the formation of a new substance with pronounced diamagnetic properties. Relying on the effect discovered, a model of magnetically controlled optical switch was proposed.