In a multi-grounded neutral distribution system with distributed generation (DG), an optimally sized neutral grounding resistor (NGR) is important to mitigate temporary overvoltage (TOV). However, a strategy to determine the optimal NGR size to mitigate the TOV caused by the non-islanding operation of DG has not been investigated. This paper introduces an algorithm to determine such a strategy, regardless of the variations in the distribution system. First, a methodology to determine the TOV is briefly introduced. Based on this methodology, an algorithm to determine the optimal size of the NGR is developed. Finally, the proposed algorithm is shown to determine the optimal NGR size to lower the TOV, regardless of the variations in distribution system.