Effects of the magnetic field on nonlinear optical properties at THz range in GaAs/AlGaAs quantum wells doped with donor atoms are investigated. Expressions for the third-order nonlinear optical susceptibilities are obtained through the solution of the density matrix equations of motion within the rotating wave approximation. Donor binding energies are calculated variationally by means of an iterative shooting algorithm. Magnetic field has strong effect on the nonlinear susceptibility: it removes the degeneracy in energies of 2p± impurity states and increases the absolute value of the nonlinearity. It is also shown that a large and tunable optical nonlinear figure of merit is possible with the magnetic field applied in the growth direction. The nonlinear optical quantities are also calculated for donor distributions with different full width at half maximum values in the absence of magnetic field and the observed features at low energy part are attributed to the increasing homogeneity in the donor distribution.