The organizations of insect societies, such as division of labor, task allocation, collective regulation, mass action responses, have been considered as main reasons for the ecological success. In this article, we propose and study a general modeling framework that includes the following three features: (a) the average internal response threshold for each task (the internal factor); (b) social network communications that could lead to task switching (the environmental factor); and (c) dynamical changes of task demands (the external factor). Since workers in many social insect species exhibit age polyethism, we also extend our model to incorporate age polyethism in which worker task preferences change with age. We apply our general modeling framework to the cases of two task groups: the inside colony task versus the outside colony task. Our analytical study of the models provides important insights and predictions on the effects of colony size, social communication, and age-related task preferences on task allocation and division of labor in the adaptive dynamical environment. Our study implies that the smaller size colony invests its resource for the colony growth and allocates more workers in the risky tasks such as foraging while the larger colony shifts more workers to perform the safer tasks inside the colony. Social interactions among different task groups play an important role in shaping task allocation depending on the relative cost and demands of the tasks.