There is no context in the bible that gives David's exact age. I cannot give you a definitive answer, because of this; however, I can give some educated guesses on how old David might have been.
Today most people/scholar's believe that David was between the ages of 8 and 15 when he was first anointed by Samuel. There is no mention of whether or not Jesse had any daughters, multiple births (twins), or more than one wife. Those details would shed more light on David's exact age. However, we can still get pretty close to the information the bible does give us.
David was the youngest of 8. Of which we know the three oldest were old enough to fight in the army. During this time you had to be at least 20 years old. This means the youngest of the three eldest had to be 20. Assuming they had a son every year after that, the absolute oldest David could have been being 15. However, we need to remember that David gets anointed in Bethlehem before the war begins. We do not know exactly how much time passes, between when Samuel comes to Bethlehem and when David goes to fight Goliath, but it's reasonable to assume a couple of years have passed since the anointing.
With this information I believe we can make an educated guess that David was probably between the ages of 9 and 11 when he was first anointed by Samuel in Bethlehem.