Formal:
* Duerme, bebé. (This is the most literal translation, but it's more formal and less common in everyday speech)
Informal:
* A dormir, mi amor. (This is more affectionate and suitable for a small child)
* A la cama, mi niño/a. (This is a common phrase for bedtime)
* Vete a dormir, pequeño/a. (This is a more direct command, but still gentle)
* Buenas noches, mi bebé. (This is more like saying "good night" and can be used for a child who is already in bed)
The best way to say it depends on the specific situation.