Although extensively studied, the exact role of sleep in learning and memory is still not very clear. Sleep deprivation has been most frequently used to explore the effects of sleep on learning and memory, but the results from such studies are inevitably complicated by concurrent stress and distress. Furthermore, it is not clear whether there is a strict time-window between sleep and memory consolidation. In the present study we were able to induce time-locked slow-wave sleep (SWS) in mice by optogenetically stimulating GABAergic neurons in the parafacial zone (PZ), providing a direct approach to analyze the influences of SWS on learning and memory with precise time-windows. We found that SWS induced by light for 30 min immediately or 15 min after the training phase of the object-in-place task significantly prolonged the memory from 30 min to 6 h. However, induction of SWS 30 min after the training phase did not improve memory, suggesting a critical time-window between the induction of a brief episode of SWS and learning for memory consolidation. Application of a gentle touch to the mice during light stimulation to prevent SWS induction also failed to improve memory, indicating the specific role of SWS, but not the activation of PZ GABAergic neurons itself, in memory consolidation. Similar influences of light-induced SWS on memory consolidation also occurred for Y-maze spatial memory and contextual fear memory, but not for cued fear memory. SWS induction immediately before the test phase had no effect on memory performance, indicating that SWS does not affect memory retrieval. Thus, by induction of a brief-episode SWS we have revealed a critical time window for the consolidation of hippocampus-dependent memory.