Due to increasing penetration of renewable distributed generation (DG), conventional distribution networks have been gradually transforming into their active form, where microgrids may serve as fundamental building blocks. As the primary step towards microgrid planning, optimal DGs placement and sizing can reduce the total energy losses by localizing power supply to loads. In this paper, a DG optimal placement method by minimizing the total energy losses is proposed, where the planning is formulated as a non-linear programming (NLP) problem. AC optimal power flow (OPF) is used to solve this planning problem by considering operational constraints and uncertainties in load and renewable power generation of the network. IEEE 33-bus test system and a real 404-bus distribution system operated by Saskatoon Light and Power in Saskatoon, Canada are used to validate the proposed method. The proposed method also shows superior performance compared to existing methods.