What are conditions to get NPC invasion at Dark Souls 3?

There are two requirements to be invaded by NPCs: You need to be embered and the area boss needs to still be alive.

If the invasion doesn't happen, you probably already defeated the boss. In the Undead Settlement that would be the Curse-Rotted Greatwood. Whether you play online or offline doesn't affect NPC invasions and if you die, you will be invaded again in the same place until you defeat the invader or kill the boss. If you already killed the boss, the only way to get the invasion on the same character is to play through the game a second time in New Game+.