(Once with a sling and once with a sword.)
David put his hand in his bag, and took thence a stone, and slang it, and smote the Philistine in his forehead, that the stone sunk into his forehead; and he fell upon his face to the earth. David prevailed over the Philistine with a sling and with a stone, and smote the Philistine, and slew him; but there was no sword in the hand of David. 1 Samuel 17:49-50
David ran, and stood upon the Philistine, and took his sword, and drew it out of the sheath thereof, and slew him, and cut off his head therewith. 1 Samuel 17:51
And David said unto Ahimelech ... And the priest said, The sword of Goliath the Philistine, whom thou slewest in the valley of Elah. 1 Samuel 21:8-9
And there was again a battle in Gob with the Philistines, where Elhanan the son of Jaareoregim, a Bethlehemite, slew the brother of Goliath the Gittite, the staff of whose spear was like a weaver's beam. 2 Samuel 21:19
The words "the brother of" were inserted by the KJV translators to avoid the obvious contradiction with 1 Samuel 17:49-51.
The slayer of Goliath the Gittite is not David but Elhanan, one of his hereoes. -- Note for 1 Samuel 17:4 in The HarperCollins Study Bible.