In order to solve the maintenance decision-making problem of the key components in a manufacturing equipment, an optimization model for maintenance decision combining the production tasks, condition-based maintenance(CBM) and opportunistic maintenance(OM) is built considering the residual value and the risk of unplanned downtime. Based on the existing works on CBM and OM, a decision on whether taking OM on the component is made for minimizing the total cost by considering the remaining useful life(RUL) and duration of the following task between two adjacent tasks. This is to decrease the maintenance cost by keeping that the task is not interrupted by equipment failures. In this paper, the inverse Gaussian process is used for component degradation modeling and computing the probabilities of different maintenance combinations. Then the objective function is built for minimizing the total cost of maintenance and the model is solved by simulation. Finally the proposed maintenance strategy is validated by numerical experiments.