Satellite networks, with their global coverage advantages, play a crucial role in supporting 6G networks. The integration of mobile edge computing into low earth orbit satellite constellations can provide ground users with low-latency and highly reliable services. Considering the randomness of ground user demands and the heterogeneity of satellite resources, which lead to imbalanced satellite workloads, the task allocation problem is formulated as a mathematical optimization model to ensure a reasonable distribution of satellite tasks. Furthermore, an improved glowworm algorithm is designed to obtain the optimal solution. Comparative evaluations with benchmark algorithms, the effectiveness of the proposed approach has been validated through simulations.