We address the development of geometric phases in classical and quantum magnetic moments (spin-1/2) precessing in an external magnetic field. We show that nonadiabatic dynamics lead to a topological phase transition determined by a change in the driving field topology. The transition is associated with an effective geometric phase which is identified from the paths of the magnetic moments in a spherical geometry. The topological transition presents close similarities between SO(3) and SU(2) cases but features differences in, e.g., the adiabatic limits of the geometric phases, being $2pi$ and $pi$ in the classical and the quantum case, respectively. We discuss possible experiments where the effective geometric phase would be observable.