The Bible does not specifically say how old David was when he fought Goliath. However, it is likely that he was already an adult at that point.
When David fought Goliath, he was already the armor-bearer to King Saul, and he was appointed to that position because of the way he soothed Saul. He was chosen to soothe Saul because he was "skillful in playing, a mighty man of valor, a man of war, prudent in speech, and a handsome person; and the Lord is with him" (1 Samuel 16:18). This implies that he was already an adult. Although he is referred to as a "youth" when he went to fight Goliath, the same Hebrew word in is later used to describe David's son Absalom when he was leading a military coup against David.