This study assumes a residential thermal and electric microgrid with distributed energy resources (DERs) composed of microturbines (MTs), photovoltaic systems (PVs), and wind turbines (WTs). The objective of this study is to find the optimal combination of MTs, PVs, and WTs for residential customers. For this purpose, this study defines the objective function to minimize not only the generation costs of electric, thermal energy, MTs, PVs, and WTs but also the voltage variations of the grid. Since HOMER can evaluate the lifecycle operating and maintenance costs of thermal and electric grids, this study evaluates the lifecycle cost functions of these DERs. If the cost function is fitted by second-order polynomials, quadratic programming (QP) can be used for an optimization problem because the cost function of QP is defined in the second order. Thus, using QP implemented in MATLAB, the optimal combination (e.g., the most effective capacity) of MTs, PVs, and WTs is determined. To validate the proposed method, an electric and thermal residential grid is modeled by the IEEE 13-bus test feeder. Using the backward and forward sweep power-flow method, the voltage variation of the test feeder enhanced by the DERs is evaluated. Next, cost functions and voltage variations are used as input to QP. A case study with the test feeder demonstrates the effectiveness of the proposed method.