It is unknown exactly when demons were created. Their purpose, however, was torturing the souls of the mortals that weren't worthy of Heaven, and some had the extra task of assisting Lucifer in his goals. Mazikeen is the only known demon to have continued to assist Lucifer after his departure from Hell.
After Lucifer's abdication, demons continued to serve their purposes in Hell, even without Lucifer there to rule over them. It is implied by Amenadiel that it was he himself who restored order after Lucifer decided to abandon Hell, which further implies that he was the ruler of the demons that reside in Hell. After his fall, it is unknown who controls the demons in Hell.