In a solar-powered microgrid (MG), the optimal maintenance strategy is influenced by the downtime cost of the photovoltaic (PV) system, which in turn depends on the operation PV within the MG network. Also, the dispatch policy used in the MG will influence the economic feasibility of maintenance plans. In this paper, we present an approach for optimizing the operation and maintenance policy jointly for a solar-powered MG considering the dependence between the two policies. The two-layered approach presented in this paper seeks to unify the practicality of simulation and the efficiency of analytical models. In the upper layer, we optimize the operation of MG by solving the optimal power dispatch within the MG network using linear programming approach. Then, we calculate the penalty costs under the aging conditions of PV systems. In the bottom layer, by incorporating the penalty costs as input parameters, we use a continuous-time Markov chain model to calculate the optimal maintenance policy for the PV system. The proposed approach could be used in the stipulation process between MG owner and PV system maintenance provider to minimize the money waste on both sides.This research was partly funded by the EPSRC/Innovate UK Centre for Smart Infrastructure and Construction (EP/N021614/1) and also supported by Sustain-Owner (Sustainable Design and Management of Industrial Assets through Total Value and Cost of Ownership), a project sponsored by the EU Framework Programme Horizon 2020, MSCA-RISE-2014: Marie Skodowska-Curie Research and Innovation Staff Exchange (Rise) (grant agreement number 645733 Sustain-owner H2020-MSCA-RISE-2014)