This study explores the Whales Optimization Algorithm (WOA)-based PI controller for regulating the voltage and frequency of an inverter-based autonomous microgrid (MG). The MG comprises two 50 kW DGs (solid oxide fuel cells, SOFCs) interfaced using a power electronics-based voltage source inverter (VSI) with a 120-kV conventional grid. Four PI controller schemes for the MG are implemented: (i) stationary PI controller with fixed gain values (Kp and Ki), (ii) PSO tuned PI controller, (iii) GWO tuned PI controller, and (iv) WOA tuned PI controller. The performance of these controllers is evaluated by monitoring the system voltage and frequency during the transition of MG operation mode and changes in the load. The MATLAB/SIMULINK tool is utilised to design the proposed model of grid-tied MG alongside the MATLAB m-file to apply an optimisation technique. The simulation results show that the WOA-based PI controller which optimises the control parameters, achieve 62.7% and 59% better results for voltage and frequency regulation, respectively. The eigenvalue analysis is also provided to check the stability of the proposed controller. Furthermore, the proposed system also satisfies the limits specified in IEEE-1547-2003 for voltage and frequency.