We consider an imperfect production system assigned to manufacturing multiple items. When the machine shifts to an out of control state, its defective rate increases. Duration of time that the machine operates in the normal state depends to the age of machine and it follows a general probability distribution. In such a system, manufacturing cost is influenced by the production sequence. We take into account the possibility of improving the production conditions by means of an age-based imperfect maintenance with several PM options. A quality screening system with variable number of inspections is also present to monitor the production state. By detecting a shift, a setup with known cost is initiated to bring the machine in the normal conditions. Proposed model addresses optimal sequence of the jobs, type of PM levels to be performed before starting the production of each lot, and the optimal number of quality inspections during its production. Lengths of the inspection intervals are determined such that the integrated hazard rates are constant. Effect of both linear and non-linear age reduction models on the optimal solution is studied and sensitivity analysis is provided to highlight the most important parameters of the model. A solution approach is provided and the model is compared to several dispatching rules from the literature.