The optimal power flow problem is extended for the grid-connected microgrid and an optimal operation model with the consideration of UC(Unit Commitment) is built. The 0 / 1 decision variables and the continuous operational variables mixed in the model are separated by the Benders decomposition and solved by the iteration between the UC main problem without network constraints and the OPF sub-problem with network constraints. Case analysis of the modified IEEE 13-bus system verifies that the proposed method can quickly and reliably optimize the operation of microgrid.