Ultra-dense computation services are widely distributed in various application scenarios with the rapid development of artificial intelligence and machine learning. Relying on the existing ground cellular networks, it is challenging to satisfy the 6G vision of full coverage and massive machine connectivity. Satellite-terrestrial integrated network (STIN) has abundant computation resources and seamless coverage ability, which can be served as an effective supplementary for the task allocating in cellular networks. Nevertheless, STIN has the characteristic of architecture complexity, unavoidable stragglers and high economic costs. The rational computation resource allocation among distributed on-orbit satellites becomes an urge problem, synthesizing these drawbacks in STINs. In this paper, to address these issues, we attempt to design a coded computation offloading strategy (CCOS) to migrate ground ultra-dense computing tasks to distributed satellite constellations in space. Considering the effect of unpredictable computation resource occupation on satellites, we investigate two coded computation methods, i.e., maximum distance separable (MDS) code and rateless code, to resist the random stragglers occurring on satellite nodes. Then, we formulate the optimization problem about minimizing the delay-energy tradeoff cost with different CCOSs under the tolerant time constraints, and obtain the optimal task offloading decisions (i.e., executing locations and coding parameters) using a proposed low-cost offloading decision searching algorithm (LODSA). Numerical simulation results show that, our coded computation strategies can significantly eliminate the effect of stragglers, and improve the cost performance obviously compared with the un-coded strategies in typical application cases.