Many attempts to switch magnetization with optical pulses were based on free-space coupling schemes of circularly polarized light pulses, so-called all-optical helicity-dependent magnetic switching; however, waveguide coupling schemes are promising for on-chip all-optical magnetic switching. Metal-insulator-metal (MIM) stub structures provide a promising platform for highly integrated photonic circuits, thanks to their compact size, on-chip compatibility, and ease of fabrication. We found clockwise and counterclockwise ring-like modes in the MIM stub structure, which can act as effective magnetic fields with two opposite directions due to the inverse Faraday effect. Effective magnetic field spectra inside the MIM stub have dual resonant peaks at which the effective magnetic field intensity reaches its extreme values with opposite signs, corresponding to binary magnetic states. Switching between the binary magnetic states can be achieved by altering the optical pump frequency. The all-optical frequency-dependent magnetic switching in the MIM stub may provide a chip-compatible and ultracompact tool for ultrafast switching of magnetic order.