Observed ostracism refers to a form of exclusion in which one observes others' experience of exclusion while also feeling the experience of exclusion. Previous studies have shown that individuals who observe the situation of exclusion will tend to produce more compensatory behaviors toward the excluded. However, these studies did not reveal the psychological mechanism of the observer's compensatory behavior. Through the experimental method, from the dynamic theoretical model of empathy and the theoretical perspective of individual-environment interaction, this study constructs a moderated mediation model with observed ostracism as the independent variable, compensation behavior as the dependent variable, empathy as the mediating variable, and observer justice sensitivity as moderating variable. The results showed that: (1) Empathy played a partial mediating role between the observed ostracism and compensation behavior. (2) Observer justice sensitivity can not only be moderating the relationship between observed ostracism and compensation behavior, but also be moderating the relationship between observed ostracism and empathy. The results of this study supported the dynamic theoretical model of empathy and bring some enlightenment to the maintenance of social norms. • Observed ostracism can induce the observer's empathy response to the excluded. • Observed ostracism can induce the observer's compensatory behavior to the excluded. • The stronger the individual's empathy response, the more compensatory behaviors to the excluded. • The higher the individual's observer justice sensitivity, the stronger the empathy response. • The higher the individual's observer justice sensitivity, the more compensation behaviors to the excluded.