We aim at finding an optimal design for an interior permanent magnet electric motor by means of a sensitivity-based topology optimization method. The gradient-based ON/OFF method has been successfully applied to optimization problems of this form. We show that this method can be improved by considering the mathematical concept of topological derivatives (TDs). TDs for optimization problems constrained by linear partial differential equations (PDEs) are well understood, whereas little is known about TDs in combination with nonlinear PDE constraints. We derive the TD for an optimization problem constrained by the equation of nonlinear 2-D magnetostatics, illustrate its advantages over the sensitivities used in the ON/OFF method, and show numerical results for the optimization of an interior permanent magnet electric motor obtained by a level-set algorithm, which is based on the TD.