In recent years, service-oriented-based Internet of Things (IoT) has received massive attention from research and industry. Integrating and composing smart objects functionalities or their services is required to create and promote more complex IoT applications with advanced features. When many smart objects are deployed, selecting the most appropriate set of smart objects to compose a service by considering both energy and quality of service (QoS) is an essential and challenging task. In this paper, we reduced the problem of finding an optimal balance between QoS level and the consumed energy of the IoT service composition to a bi-objective shortest path optimization (BSPO) problem and used an exact algorithm named pulse to solve the problem. The BSPO has two objectives, minimizing the QoS including execution time, network latency, and service price, and minimize the energy consumption of the composite service. Experimental evaluations show that the proposed approach has short execution time in various complex service profiles. Meanwhile, it can obtain good performance in energy consumption and thus network lifetime while maintaining a reasonable QoS level.