The sword of Goliath was originally taken by David as his share of the plunder following his victory (1 Samuel 17:51).1 Since the Lord had given him the victory, it appears as if he gave his plunder to the Lord. The sword of Goliath may well have been given to Ahijah the priest after the battle (see 1 Samuel 14:2) who then took it to his brother Ahimelech at the sanctuary of Nob.
9 And the priest said, “The sword of Goliath the Philistine, whom you struck down in the Valley of Elah, behold, it is here wrapped in a cloth behind the ephod. If you will take that, take it, for there is none but that here.” And David said, “There is none like that; give it to me.”