Adverse social experience affects social structure by modifying the behavior of individuals, but the relationship between an individual's behavioral state and its response to adversity is poorly understood. We leveraged naturally occurring division of labor in honey bees and studied the biological embedding of environmental threat using laboratory assays and automated behavioral tracking of whole colonies. Guard bees showed low intrinsic levels of sociability compared with foragers and nurse bees, but large increases in sociability following exposure to a threat. Threat experience also modified the expression of caregiving-related genes in a brain region called the mushroom bodies. These results demonstrate that the biological embedding of environmental experience depends on an individual's societal role and, in turn, affects its future sociability.