As a technology integrated with Internet of Things (IoT), mobile edge computing (MEC) can provide real-time and low latency services to the underlying network, and improve the storage and computation ability of the networks instead of central cloud infrastructure. In Mobile Edge Computing based Internet of Vehicle(MEC-IoV), the vehicle users can deliver their tasks to the associated MEC servers Based on offloading policy, which improves the resource utilization and computation performance greatly. However, how to evaluate the impact of uncertain interconnection between the vehicle users and MEC servers on offloading decision-making and avoid serious degradation of the offloading efficiency are important problems to be solved. In this paper, a task-offloading decision mechanism with particle swarm optimization for IoV-based edge computing is proposed. First, a mathematical model to calculate the computation offloading cost for cloud-edge computing system is defined. Then, the particle swarm optimization (PSO) is applied to convert the offloading of task into the process and obtain the optimal offloading strategy. Furthermore, to avoid falling into local optimization, the inertia weight factor is designed to change adaptively with the value of the objective function. The experimental results show that the proposed offloading strategy can effectively reduce the energy consumption of terminal devices while guarantee the service quality of users.