The nightly shape of melatonin release
Melatonin is produced by the pineal gland under control of the brain's master clock in the suprachiasmatic nucleus. Secretion is low during the day, begins to rise in the couple of hours before habitual sleep onset (a point researchers call the dim-light melatonin onset), reaches its peak in the middle of the night, often around 02:00 to 04:00, then declines toward morning.
Light is the dominant external cue. Bright light, especially shorter blue wavelengths, suppresses melatonin and can shift the timing of the whole curve, while darkness permits its rise. This is why evening light exposure is studied as a factor in delayed sleep timing.
How the curve changes across life and circumstances
The amplitude of the nightly peak tends to be high in childhood and to decline gradually with age. The timing of the curve also differs by chronotype, so an early type peaks earlier than a late type. Travel across time zones and shift work temporarily desynchronize the curve from the local clock.
Melatonin is part of timing sleep, not a sedative that forces it, and supplement use, dosing, and timing should be discussed with a qualified clinician. This is general educational information, not medical advice.