We present a theoretical framework to describe experiments directed to controlling single-atom spin dynamics by electrical means using a scanning tunneling microscope. We propose a simple model consisting of a quantum impurity connected to electrodes where an electrical time-dependent bias is applied. We solve the problem in the limit of weak coupling between the impurity and the electrodes by means of a quantum master equation that is derived by the nonequilibrium Green's function formalism. We show results in two cases. The first case is just a single atomic orbital subjected to a time-dependent electric field, and the second case consists of a single atomic orbital coupled to a second spin-1/2. The first case reproduces the main experimental features of Ti atoms on MgO/Ag (100) while the second one directly addresses the experiments on two Ti atoms. These calculations permit us to explore the effect of different parameters on the driving of the atomic spins as well as to reproduce experimental fingerprints.