To realize a harmonized relationship between human and computational systems, it is necessary to understand the nature of empathy for a virtual agent and the kinds of behaviors elicited by such mental activity. By setting a ball-tossing game in which a participant and two virtual agents were involved, we examined how ostracism experiences affect cognitive empathy and how embodiment induced by VR (Virtual Reality) influences behaviors that elicit emotional empathy. Thirty-two participants were divided into two groups by manipulating the experience of being ostracized in the preparatory task. In the main task, the participants played the game under two conditions: an equitable condition, in which the virtual agents tossed the ball evenly to the participant and the other agent, and an inequitable condition, in which one agent tossed the ball only to the participant. The data obtained in the experiment was analyzed from the viewpoint of helping behaviors to the agent who was ostracized and examined the relation of this behavior with the EQ (Empathy Quotient), an index to measure an individual's empathetic traits. As a result, the ostracized experience made the participants notice the ostracizing behaviors of the agent and fostered helping behavior toward the agent who was ostracized. In addition, the participants with a high EQ tended not to notice the ostracizing behavior in the situation without embodiment induced by VR, whereas they exhibited more helping behaviors when they experienced the task with the VR device. We consider that these findings contribute to the design of smoother interaction between humans and virtual agents.