Mobile edge computing (MEC) is a transformative paradigm that enhances mobile services performance and operational efficiency. Given the frequent mobility of users, it is essential to migrate services to continuously align with user movements. However, making service migration decisions requires careful consideration of factors like latency, resource availability, and user demand to ensure optimal performance and user satisfaction. Therefore, in this paper, we first formulate the service migration in MEC systems as an optimization problem, with the objective of minimizing the system’s energy consumption and migration cost while considering delay as the model's constraint. Next, we propose an energy-efficient, cost-effective and QoS-aware heuristic-based method, called ECQ, to effectively solve the model. To reflect a comprehensive understanding of real-world MEC environments, we also consider the incorporation of heterogeneous server configurations and the non-universal presence of servers across all base stations. By accommodating these aspects, ECQ emerges as a promising solution for the dynamic service migration optimization challenges in time-sensitive and realistic MEC contexts. Finally, through various simulation scenarios, the performance of the proposed ECQ is evaluated in terms of response time, migration costs, energy consumption, and the number of migrations. The results demonstrate that the proposed algorithm outperforms other methods in terms of overall performance; specifically, it ensures high QoS for users while sustainably managing the system's energy consumption and keeping migration costs within acceptable levels. In particular, when compared to the FullMig strategy, the proposed method achieves a noteworthy reduction in migration costs and energy consumption by approximately 25% and 50%, respectively. Meanwhile, the average response time in FullMig is only about 12% less than that of our method. Additionally, in comparison to the E-ware method, our ECQ exhibits an impressive response time reduction of approximately 42%, all while maintaining migration costs and energy consumption at levels comparable to the E-ware approach.