Distributed energy systems (DESs) have garnered significant attention because of their flexibility and high efficiency. Owing to the diversity of user demand and the complex composition of the DES, the optimization of operation and planning for the entire system is complex. A mixed integer linear programming (MILP) model can be used to solve the optimization problem effectively. Different nonlinear factors should be considered and linearized in the model such that it is more accurate and practical for application. It is important to match waste heat recovery technologies (WHRTs) with various heat sources of different temperatures based on energy quality, which can improve efficiency of the entire system. Consequently, a new method is proposed herein to match multiple heat sources with various WHRTs and heat storage of different temperatures in the MILP optimization model. The optimization model can select the most suitable WHRTs, including their capacity for the DES, according to energy quality and user demand. Additionally, a one-year operating schedule of all the technologies can be optimized. The practicability of the method in real applications is validated by the dynamic simulation of waste heat distribution to different WHRTs. Hence, two cases are studied. One case indicates that the model can match the WHRTs with multiple heat sources of different temperatures with a short time needed to solve the optimization (22 s with a gap of 0.001%). The other case proves that the model can distinguish the energy qualities of low- and high-temperature heat storage, and that a 1189 kWh output cooling during a typical day is increased by high-temperature heat storage.