Understanding the photoexcitation induced spin dynamics in ferromagnetic metals is important for the design of photo-controlled ultrafast spintronic device. In this work, by the ab initio nonadiabatic molecular dynamics simulation, we have studied the spin dynamics induced by spin–orbit coupling (SOC) in Co and Fe using both spin-diabatic and spin-adiabatic representations. In Co system, it is found that the Fermi surface (E F) is predominantly contributed by the spin-minority states. The SOC induced spin flip will occur for the photo-excited spin-majority electrons as they relax to the E F, and the spin-minority electrons tend to relax to the E F with the same spin through the electron–phonon coupling (EPC). The reduction of spin-majority electrons and the increase of spin-minority electrons lead to demagnetization of Co within 100 fs. By contrast, in Fe system, the E F is dominated by the spin-majority states. In this case, the SOC induced spin flip occurs for the photo-excited spin-minority electrons, which leads to a magnetization enhancement. If we move the E F of Fe to higher energy by 0.6 eV, the E F will be contributed by the spin-minority states and the demagnetization will be observed again. This work provides a new perspective for understanding the SOC induced spin dynamics mechanism in magnetic metal systems.