Locate Object can find 'any' object as long as there's no lead between the caster and the object.
Even if the object is lead.
The material make up of the object in question is never specified, the only specific limitations is if there's lead between you and it, its over 1,000 feet away, or if you don't know the specific object, then you're only able to locate the nearest object of a particular 'kind'.
Full spell text:
Describe or name an object that is familiar to you. You sense the direction to the object’s location, as long as that object is within 1,000 feet of you. If the object is in motion, you know the direction of its movement.
The spell can locate a specific object known to you, as long as you have seen it up close—within 30 feet—at least once. Alternatively, the spell can locate the nearest object of a particular kind, such as a certain kind of apparel, jewelry, furniture, tool, or weapon.
This spell can’t locate an object if any thickness of lead, even a thin sheet, blocks a direct path between you and the object.
Darkness (usually) cancels out all Advantage and Disadvantage effects for people affected
This is because of two basic rules that affect how combat resolves.
For the person outside the Darkness:
- They cannot see the target (even if they know their location, which they do unless the target uses the Hide action), so they have Disadvantage on their Attack Rolls
- Their target cannot see them, so they have Advantage on their Attack Rolls
This is symmetric for the person inside the Darkness as well: they cannot see anyone they attack, and anyone they attack cannot see them either.
The semantics of these rules are found in the Unseen Attackers paragraph of the Making an Attack section of Chapter 9 of the Player's Handbook:
Combatants often try to escape their foes' notice by hiding, casting the invisibility spell, or lurking in darkness.
When you attack a target that you can't see, you have disadvantage on the attack roll. This is true whether you're guessing the target's location or you're targeting a creature you can hear but not see. If the target isn't in the location you targeted, you automatically miss, but the DM typically just says that the attack missed, not whether you guessed the target's location correctly.
When a creature can't see you, you have advantage on attack rolls against it.
If you are hidden—both unseen and unheard—when you make an attack, you give away your location when the attack hits or misses.
Since Advantage and Disadvantage cancel each other, and you don't consider stacked effects (i.e. 2 Advantage sources + 1 Disadvantage source doesn't result in net Advantage), Darkness almost always results in all advantage + disadvantage being negated for all affected creatures.
Shadow Sorcerers, Devil's Sight, and True Sight break this Symmetry
There are three features in 5th edition D&D that alter this situation.
- When Shadow Sorcerers cast the Darkness spell using their own Sorcery Points, they are explicitly permitted to see through their own Darkness spell
- Any creature that has the feature Devil's Sight (most high CR Devils, and Warlocks that take the Devil's Sight Eldritch Invocation) can treat all Darkness, even magical Darkness, as Dim Light (which has no effect on Attack Rolls)
- Any creature that has the feature True Sight (some creatures, as well as anyone who has the Truesight spell cast on them) may ignore Magical Darkness entirely, as though it's not there
In each of these situations, the Unseen Attackers rule comes into play, where the creatures that have at least one of these features will have advantage against any creatures that don't when attacking them, and said target creatures when attacking will have Disadvantage against their better-sighted assailants.
So what's the point?
Well, for starters, it does negate Advantage that your opponents might have. That's one good use.
Secondly, it makes it easy to Hide. Hideing requires some kind of cover, or some ability to stop the enemy from seeing you. So long as that dagger is out, the creature trying to evade the enemy can Hide as an action whenever they want, and if their Dexterity(Stealth) roll is high enough, their location becomes unknown to their enemy (though known to be somewhere inside the Darkness bubble), which will make it much harder to hit them, even without Disadvantage on their attack rolls.
Resolving the unknown location, mechanically, is DM fiat; generally, the DM makes creatures target random points within the bubble, and if they're more than 5' from the creature, they're not close enough to hit them. Otherwise, they use their Action to use the Search action, and if they roll high enough, they're able to know the location of their target
Another important use of Darkness is to prevent spellcasting that requires visible targets. The vast majority of spells, especially single-target spells, require visibility of the target in question; obscuring vision with Darkness makes such spells unusable.
Best Answer
RAW: no, this would not work.
Remember that spells only do what they say they do. The description of the Locate Object spell says:
So we have to meet the conditions for the spell to work, and the big one here is object.
In D&D 5E, an object is explicitly defined as (emphasis mine):
So even if the heart in question were an inanimate object (which it doesn't sound like it is), it might be hard to pull off since it's part of a greater whole (the NPC).
Using the spell the way you describe also undermines the 4th-level spell Locate Creature, which is explicitly intended to locate living things.
However, your DM may rule otherwise because it's clever and cool.
All that said, it seems like the scenario you find yourselves in lends itself to using the Locate Object spell in this way, and it may have been your DM's intention for you to do this. Depending on the circumstances, a DM might "rule of cool" that your suggested use of the spell could work, but since we aren't meeting the various other conditions like the caster having seen the heart, etc. then I'm personally disinclined to rule as such.
If the heart is separate, however, you might be able to pull this off, but your caster would still have to have a pretty good idea of what the object looks like.
So ultimately, it will come down to your DM, but RAW, no, this does not work if the heart is inside the NPC.
An example where this might work: if the heart is artificial, like made of stone, and if your caster is familiar with it, it may be a valid target for this spell.