A lost soul that targets a monster will do so only until it makes an attack against the monster. After that, the target is forgotten. Since the lost soul always goes into its pain state when damaged, it will target its opponent again once said opponent retaliates successfully, although it can easily be distracted by other attackers.
When attacking a player, lost souls retain it as their target as long as the player makes at least one attack that alerts them in their area. If the player does not make such an attack, lost souls that lose sight of their target will go dormant. This is easy to test in Doom's E2M8: Tower of Babel by going to the outside area without attacking at all, and letting the lost souls charge at the player, but dodging them. These will strike the walls and become dormant until they see or hear the player. Using a weapon will awaken them, and from then on they will continue active, pursuing and attacking the player normally.