Terahertz emission in GaAs/AlGaAs quantum well structures doped with shallow impurities was studied in conditions of interband optical excitation for n-doped structures and impurity breakdown in the lateral electric field for p-doped structures. Emission spectra were obtained. It was shown that the observed emission is related to optical transitions of charge carriers between impurity levels and to impurity-band transitions. The depopulation of the final states under interband optical pumping was realized with recombination of non-equilibrium holes and electrons localized at neutral donors.