The ubiquity of mobile devices creates a rapidly growing market for mobile applications. Many of these applications involve complex processing tasks that are difficult to run on resource constrained mobile devices. This leads to the emergence of mobile cloud computing, in which cloud-based resources are used to enhance the computing capabilities of mobile devices. In this paper, we consider heterogeneous wireless networks in which multiple resource-rich computing nodes can be used as mobile clouds, and mobile devices can upload computation extensive tasks to these mobile clouds. The goal is to minimize the average task response time through determining whether to upload a task, and to which cloud the task should be uploaded. We formalize this task allocation problem, which is proved to be a NP-hard problem, and propose both offline centralized approach and online distributed approach to address this problem. Simulation results show that our approaches outperform others in terms of task response time in various scenarios.