My merchant is stuck a long way down in a cave and I'd like to get him back into my house. I can't make a track back up because it would take an extremely long time. Any ideas?
+1 to Havatra, however his answer is incomplete.
The NPC will only teleport back to its house when night falls. So when the sun is setting, leave your house, or if you do not have good enough weapons to survive the monsters, go out during the day and build a small shack to protect you. Dirt will work fine. An easy way to do this is to dig 3 blocks down and then place a roof on top. This leaves you with no room to move (unless you dig), but it is the easiest way to build a safe place for the night.
Another way to do this is to use a king/queen statue and wiring. A king statue will teleport a random male NPC, whereas a queen statue will teleport a female one. They will do this when they are activated by an active wire. This method however requires you to have progressed a fair bit into the game, by which time you will have many NPCs and the chance of teleporting the merchant is quite small.
As long as your NPC is a part of a suitable housing, the NPC will magically despawn and respawn in his/her house when you are not looking. With other words, just move far enough away from the housing, and do something else meanwhile. Most likely, the next time you go back to the house, he'll be there.
The NPC can teleport to the house if he wandered off too far, but what you can do if you want to do it the
fun way take advantage of his AI.
He moves left and right. Make a staircase so he can jump up out then place blocks so he can walk back home. Or you could get a new one by killing a guide voodoo doll (Put stuff in chest first, as this will summon the wall of flesh!) Also this method requires you to make it to hell.