That sounds very much like "The Misenchanted Sword" by Lawrence Watt-Evans
A soldier by the name of Valder is on patrol. The enemy forces notice him spying, and send a small group (including a half demon "Shatra") to capture (or more likely kill) him.
Valder gains ground, but cannot get away from those following him.
Eventually, he runs across the camp of a retired wizard. Before Valder can explain that he is being followed by the bad guys, they attack and destroy the wizard's house.
The wizard disguises himself and Valder as corpses, and the enemy soldiers leave.
The wizard is really unhappy that his house and many of his special magical things were destroyed, but he agrees to help Valder get back to his unit.
The wizard spends most of a day casting spells on Valder's sword. He doesn't tell Valder what exactly all the spells do. He just tells Valder that the sword now has a name ("Wirikidor," which means "slayer of warriors" or some such.) The wizard also tells him not to draw the sword until he has left the wizard's camp.
The wizard then packs up and leaves overnight, leaving Valder alone with the sword.
Valder discovers that the sword can't be put back in its sheath until it has killed someone, and that it turns him into an unbeatable swordsman. But, it can only handle one foe each time it is drawn, and must be sheathed and redrawn to take on the next.
The Army's wizards analyse it, and discover some things about it:
- It uses a spell to remain razor sharp at all times.
- It uses a spell called "Elran's immortal animation" to make it move and fight.
- It uses a spell called "the spell of true ownership" to make the sword obey only Valder, and to make it always stay close to him.
- Valder's life is tied to the spells - he cannot die as long as the spells hold.
- The name "Wirikidor" would be better translated as "man killer."
There's another thing to complicate the whole mess: The spell of true owership was done wrong. It will not obey Valder forever. After he has used the sword one hundred times, the sword will kill him. The next person who uses it will get to use it 99 times, and after that 98. At some point, some sap will draw the sword and it will immediately kill him.
The rest of the story tells how the war ends, and Valder goes on to try to live a normal life despite the sword and its side effects.
Valder does become a tavern owner, and keeps the sword on the wall above the fireplace in the tavern.
Valder's sword is not made from the swords of fallen enemy soldiers. The wizard does keep Valder busy collecting odd items needed to cast the spells, though.
Other than that , I think "The Misenchanted Sword" fits your description pretty well. It is even the first of a series of books set in the world of Ethshar.
One of the few fantasy stories I've ever read and enjoyed. I mostly dislike fantasy, but this is a really good story.
I've read another couple of books from the same series, and they were also pretty good.