The efficiency of distributed energy systems can be significantly increased through waste heat recovery from industry or power generation. The technologies used for this process are typically dependent on the quality and temperature grades of waste heat. To maximize the efficiency of cascade heat utilization, it is important to optimize the choice of waste heat recovery technologies and their operation. In this paper, a detailed mixed integer linear programming optimization model is proposed for waste heat recovery in a district-scale microgrid. The model can distinguish waste heat quality for planning and operation optimization of distributed energy systems. Heat utilization technologies are formulated in this developed model and categorized in different temperature grades. The developed model is validated using four typical cases under different settings of system operation and business models. It is found that the optimization model, by distinguishing waste heat temperature, can increase energy cost savings by around 5%, compared to models that do not consider waste heat temperature grades. Additionally, the results indicate that the developed model can provide more realistic configuration and technologies dispatch.