Distributed Generation (DG), especially photovoltaic distributed generation (PVDG), has contributed significantly to serving the growing demand for active power. However, the necessity to meet the demand for reactive power is still challenging. In addition to active power generation, photovoltaic inverters can be used to provide ancillary services to the grid, including reactive power compensation. This paper proposes a metaheuristic approach based on Particle Swarm Optimization (PSO) for allocation and sizing of photovoltaic inverters performing the complementary function of static synchronous compensator (PV-STATCOM) units. The objective function of the above-mentioned approach is to minimize the initial investment in the acquisition of PV-STATCOM units. The proposed methodology takes into account both daily load curve and generation and is applied to the 33 Bus Test System. The results show improved grid voltage profile throughout the day. Also, the photovoltaic inverter did not fail to perform its main function, i.e., that of generating active power. One of the major contributions of the proposed methodology is that it will assist investors in determining the allocation and sizing of PV-STATCOM units to perform the ancillary service of reactive power compensation in the grid.