It depends on the model Tamagotchi toy you have. There are two different behaviors:
(1) On some models, when your Tamagotchi character goes to sleep, the lights stay on. In this case you need to turn the lights off. If you leave them on all night long, it'll count as a care miss (bad care).
(2) On other models, your Tamagotchi character turns the lights off when they go to sleep, so you don't need to do it.
Each Tamagotchi character has predetermined time when they go to sleep and when they will wake up. Turning the light off or leaving it on won't change when they wake up. However, bedtime is a different story. On some models, you'll see your Tamagotchi character occasionally yawn when it starts to get close to their bed time. If you turn off the lights during this period, they'll go to bed early. Similarly, on some models, your Tamagotchi character may go to bed a bit early if it's close to their bed time AND you haven't touched any buttons for a while. On most models, your Tamagotchi character sleeps throughout the night, but on some models, it's possible to wake up your Tamagotchi character (during the night). If she went to bed early, and it's still not yet her bedtime, she'll wake up and you can play with her until her bedtime. However, if it's past her bedtime, and you woke her up, she'll wake up in a bad mood and won't let you play with her. (The only possible reason I can think of for having feature is that it'll allow you to administer medicine to her, if she went to bed while ill and you're planning on staying up all night watching LOL cat videos on YouTube, so won't be able to get up in the morning as early as she'll get up to give her medicine then.)