In condition-based maintenance (CBM) with periodic inspection, the system is preventively replaced if failure risk, which is calculated based on the information obtained from inspection, exceeds a pre-determined threshold. The determination of optimal replacement threshold is often based on the minimisation of average maintenance costs per unit time due to preventive and failure replacements over a long time horizon. It is often assumed that inspections are performed at equal time intervals with no cost. However, in practice, inspections require labour, specific test devices, and sometimes suspension of operations and, thus, it is reasonable to inspect less frequently during the time the system is in its early age and/or in a healthier state and to perform inspections more frequently as time passes and/or as the system degrades. In other words, an age-based inspection scheme. This paper proposes a novel two-phase approach for the determination of an optimal replacement threshold and an optimal age-based inspection scheme for CBM such that the total long-run average costs of replacements and inspections are minimised. First, it takes into account failure and preventive replacement costs to determine the optimal replacement threshold assuming that inspections are performed at equal time intervals with no cost. This assumption is, subsequently, relaxed and its consequences on total average cost are evaluated using a proposed iterative procedure based on A* search algorithm to obtain the optimal age-based inspection scheme. The proposed approach is illustrated through a numerical example.