Mobile edge computing (MEC) enhanced satellite based internet of things (SAT-IoT) is an important complement for terrestrial networks based IoT, especially for the remote and depopulated areas. For MEC enhanced SAT-IoT networks with multiple satellites and multiple satellite gateways, the coupled user association, offloading decision, computing and communication resource allocation should be jointly optimized to minimize the latency and energy cost. In this paper, the latency and energy optimization for MEC enhanced SAT-IoT networks are formulated as a dynamic mixed-integer programming problem, which is hard to obtain the optimal solutions. To tackle this problem, we decompose the complex problem into two sub-problems. The first one is computing and communication resource allocation with fixed user association and offloading decision, and the second one is joint user association and offloading with optimal resource allocation. For the sub-problem of resource allocation, the optimal solution is proven to be obtained based on Lagrange multiplier method. And then, the second sub-problem is further formulated as a Markov decision process (MDP), and a joint user association and offloading decision with optimal resource allocation (JUAOD-ORA) is proposed based on deep reinforcement learning (DRL). Simulation results show that the proposed approach can achieve better long-term reward in terms of latency and energy cost. INDEX TERMS Latency and energy optimization, MEC, SAT-IoT, deep reinforcement learning.