Mobile edge computation (MEC) has recently emerged as a promising computing paradigm for supporting latency-sensitive mobile applications. Due to the limited resources of the edge servers (ESs), efficient resource allocation mechanisms are key to realize the MEC paradigm. In such a resource allocation process, it is a significant challenge to guarantee truthfulness while enabling flexible task offloading and satisfying the locality constraint. To address such a challenge, we propose a truthful auction-based resource allocation mechanism with flexible task offloading (TARFO) in an MEC system. Specifically, we first design the minimum delay task graph partitioning algorithm, aiming at calculating the minimum completion time and the task offloading solutions under different resource profiles. Based on this algorithm, for each smart mobile device (SMD), we further determine the set of feasible non-dominated resource profiles and the corresponding task offloading solutions. We next propose an efficient primal-dual approximation winning bid selection algorithm to determine the set of the winning bids and a critical value based pricing algorithm to calculate the payments of the winning bids. Strict theoretical analysis demonstrates TARFO can ensure truthfulness, individual rationality, computational efficiency and a smaller approximation ratio. Simulation results verify the effectiveness and efficiency of TARFO.