In this paper, single-product single-machine systems under Markovian deterioration of machine condition throughout a specified finite planning horizon are studied. It is assumed that a machine is subject to random failures and that any maintenance activities applied to it in a period reduce the system's potential production capacity during that period. Furthermore, it is assumed that the machine is minimally repaired upon failure, and PM is carried out, after inspection, to restore the machine to the `as-good-as-new' status. The objective of the study is to find the optimal intervals for inspection and Preventive Maintenance (PM) activities in Condition-Based Maintenance (CBM) planning with a discrete monitoring framework subject to minimize the sum of inspection, PM, minimal repair, and backlog costs. To this end, a stochastic dynamic programming model that enumerates demand is presented, called the demand-driven CBM model. The numerical results show that this model significantly decreases the total cost which depends on the demand and the unit backlog cost, which is an increasing and concave function in the unit backlog cost regardless of the initial machine state. (c) 2023 Sharif University of Technology. All rights reserved.