As a core component of 6G networking, low earth orbit (LEO) satellite networks are considered a promising solution for providing network services in remote areas and have received considerable attention in recent years. Meanwhile, with the rapid development of IoT terminals and applications, an increasing emphasis has been placed on task offloading for real-time tasks. However, most existing works on task offloading for integrated satellite–terrestrial IoT (IST-IoT) applications are based on the assumption that the global task and network information is known, an assumption that is obviously not met in online real-time task offloading. In addition, current studies rarely consider the tradeoff among the task offloading volume, satellite endurance and wholesale cost of terrestrial resources, which are precisely the holistic issues that satellite network operators must confront. To address such issues, this study considers task offloading, service deployment and resource allocation in highly dynamic online task offloading scenarios with the goal of maximizing the average task offloading volume. Moreover, virtual queues are constructed in this study to account for the impacts of long-term satellite endurance and terrestrial network resource costs on task offloading. We first decouple the original problem to obtain a single-time-slot optimization problem within the Lyapunov optimization framework, and we then propose a 2-stage optimization approach based on deep reinforcement learning (DRL) to solve the complex single-time-slot mixed integer nonlinear programming (MINLP) problem. Simulation experiments demonstrate that our proposed algorithm can yield near-optimal solutions that show superior performance compared to existing results.