In this paper we develop a framework to analyze the behavior of contagion and spreading processes in complex subpopulation networks where individuals have memory of their subpopulation of origin. We introduce a metapopulation model in which subpopulations are connected through heterogeneous fluxes of individuals. The mobility process among communities takes into account the memory of residence of individuals and is incorporated with the classical susceptible-infectious-recovered epidemic model within each subpopulation. In order to gain analytical insight into the behavior of the system we use degree-block variables describing the heterogeneity of the subpopulation network and a time-scale separation technique for the dynamics of individuals. By considering the stochastic nature of the epidemic process we obtain the explicit expression of the global epidemic invasion threshold, below which the disease dies out before reaching a macroscopic fraction of the subpopulations. This threshold is not present in continuous deterministic diffusion models and explicitly depends on the disease parameters, the mobility rates, and the properties of the coupling matrices describing the mobility across subpopulations. The results presented here take a step further in offering insight into the fundamental mechanisms controlling the spreading of infectious diseases and other contagion processes across spatially structured communities.