AbstractSocial insect colonies are capable of allocating their workforce in a decentralised fashion; addressing a variety of tasks and responding effectively to changes in the environment. This process is fundamental to their ecological success, but the mechanisms behind it remain poorly understood. While most models focus on internal and individual factors, empirical evidence highlights the importance of ecology and social interactions. To address this gap we propose a game theoretical model of task allocation. Individuals are characterised by a trait that determines how they split their energy between two prototypical tasks: foraging and regulation. To be viable, a colony needs to learn to adequately allocate its workforce between these two tasks. We study two different processes: individuals can learn relying exclusively on their own experience, or by using the experiences of others via social learning. We find that social organisation can be determined by the ecology alone, irrespective of interaction details. Weakly specialised colonies in which all individuals tend to both tasks emerge when foraging is cheap; harsher environments, on the other hand, lead to strongly specialised colonies in which each individual fully engages in a single task. We compare the outcomes of self-organised task allocation with optimal group performance. Counter to intuition, strongly specialised colonies perform suboptimally, whereas the group performance of weakly specialised colonies is closer to optimal. Social interactions lead to important differences when the colony deals with dynamic environments. Colonies whose individuals rely on their own experience are more exible when dealing with change. Our computational model is aligned with mathematical predictions in tractable limits. This different kind of model is useful in framing relevant and important empirical questions, where ecology and interactions are key elements of hypotheses and predictions.