Dynamical process for switching between the metastable ordered magnetic state and the nonmagnetic ground state in a photoinduced phase transition