A task migration scheme for homogeneous chip multiprocessors (CMP) is presented in this paper. The proposed migration mechanism focuses on the communication sub-system and aims to reduce the total power consumption and latency of the network-on-chip (NoC). In this work, starting from an initial mapping, the tasks migrate to new cores in such a way that the distance between the end-point nodes of high-volume communication flows is reduced. Finding the new place for a task is done in a distributed manner by applying an iterative local search that relies on the local information of each task about its communication demand. The task migration procedure also includes a pre-migration step that aims to produce a high quality (i.e. closer to the optimum point) starting point for the main distributed algorithm. The experimental results under some synthetic and realistic CMP workloads show that this method can effectively adapt the mapping of the tasks to the on-chip communication pattern and improve the power consumption and performance of the on-chip networks.