If a player has batted out of order and there has been a third out of a half-inning, the defensive team must appeal the batting out of order situation before their infielders leave fair territory. If they don’t do so, the player who had batted out of order becomes legal. The next time that team comes up to bat, the batting order picks up with the player who is listed after the legalized batter.
[OBR: the appeal can be made at any time before the next pitch or play is made. This includes inning-ending situations.