The increasing integration of distributed energy resources such as photovoltaic (PV) systems into distribution networks introduces intermittent and variable power, leading to high voltage fluctuations. High PV integration can also result in increased terminal voltage of the network during periods of high PV generation and low load consumption. These problems can be solved by optimal utilization of the reactive power capability of a smart inverter. However, solving the optimization problem using a detailed mathematical model of the distribution network may be time-consuming. Due to this, the optimization process may not be fast enough to incorporate this rapid fluctuation when implemented in real-time optimization. To address these issues, this paper proposes a co-simulation-based optimization approach for optimal reactive power control in smart inverters. By utilizing co-simulation, the need for detailed mathematical modeling of the power flow equation of the distribution network in the optimization model is eliminated, thereby enabling faster optimization. This paper compares three optimization algorithms (improved harmony search, simplicial homology global optimization, and differential evolution) using models developed in OpenDSS and DigSilent PowerFactory. The results demonstrate the suitability of the proposed co-simulation-based optimization for obtaining optimal setpoints for reactive power control, minimizing total power loss in distribution networks with high PV integration. This research paper contributes to efficient and practical solutions for modeling optimal control problems in future distribution networks.