In response to challenges such as voltage limit violations, excessive currents, and power imbalances caused by the integration of distributed photovoltaic (distributed PV) systems into the distribution network, this study proposes at two-level optimization configuration method. This method effectively balances the grid capacity and reduces the active power losses, thereby decreasing the operating costs. The upper-level optimization enhances the distribution network’s capacity by determining the siting and sizing of distributed PV devices. The lower-level aims to reduce the active power losses, improve the voltage stability margins, and minimize the voltage deviations. The upper-level planning results, which include the siting and sizing of the distributed PV, are used as initial conditions for the lower level. Subsequently, the lower level feeds back its optimization results to further refine the configuration. The model is solved using an improved second-order oscillating chaotic map particle swarm optimization algorithm (SCMPSO) combined with a second-order relaxation method. The simulation experiments on an improved IEEE 33-bus test system show that the SCMPSO algorithm can effectively reduce the voltage deviations, decrease the voltage fluctuations, lower the active power losses in the distribution network, and significantly enhance the power quality.