Newly acquired memory traces are spontaneously reactivated during slow-wave sleep (SWS), leading to the consolidation of recent memories. Empirical studies found that sensory stimulation during SWS can selectively enhance memory consolidation with the effect depending on the phase of stimulation. In this new study, we aimed to understand the mechanisms behind the role of sensory stimulation on memory consolidation using computational models implementing effects of neuromodulators to simulate transitions between awake and SWS sleep, and synaptic plasticity to allow the change of synaptic connections due to the training in awake or replay during sleep. We found that when closed-loop stimulation was applied during the Down states of sleep slow oscillation, particularly right before the transition from Down to Up state, it significantly affected the spatiotemporal pattern of the slow waves and maximized memory replay. In contrast, when the stimulation was presented during the Up states, it did not have a significant impact on the slow waves or memory performance after sleep. For multiple memories trained in awake, presenting stimulation cues associated with specific memory trace could selectively augment replay and enhance consolidation of that memory and interfere with consolidation of the others (particularly weak) memories. Our study proposes a synaptic-level mechanism of how memory consolidation is affected by sensory stimulation during sleep.