In Expert Mode, all enemies have double health and all pre-Hardmode enemies receive a further health bonus when in Hardmode. Because of this, all enemies in the Dungeon that can be killed can spawn Dungeon Spirits, except for Cursed Skulls.
In Master Mode, all enemies have a further health increase, putting Cursed Skulls above 100 maximum health, which allows them to spawn Dungeon Spirits as well.
The chance of a Dungeon Spirit spawning is affected by the closest player's luck.
An easy way to farm Dungeon Spirits is to find or place a Water Candle in a large room that has many tunnels leading into it and use the Piranha Gun on enemies, as the weapon will automatically chase the Dungeon Spirit when it spawns.
Increasing the player's luck by placing a Garden Gnome and/or drinking one of the various Luck Potions will increase the likelihood that killed enemies will spawn a Dungeon Spirit.
In Expert Mode, summoning King Slime in the Dungeon will provide a decent amount of Ectoplasm, as his Blue and Spiked Slimes can summon Dungeon Spirits.
If the player has an active Wisp in a Bottle, Dungeon Spirits may blend in and be mistaken as the Wisp, as they look very similar. Dyeing the Wisp is an effective way around this without dismissing the light pet.
The Dungeon Spirit is the icon of the achievement "Robbing The Grave".
The Bestiary entry for the Dungeon Spirit: "Sometimes, highly concentrated ectoplasm gathers inside the more powerful of the cursed inhabitants of the Dungeon."