It is not easy to answer this question, in which age Bach started to compose. It depends, what you connect to the word "composing", which changes the date related to the question. It's a fact that Bach is considered only almost a child genius, by no means in the ranking of a Wolfgang Amadeus Mozart. Few scientists assume, that some works already in Ohrdruf came into being, when Bach was a young as ten years when he arrived: some preludes and some fugues.
Latest science, discovered as late as in the 21st century tells of the existence of a choral fantasy of Bach from his time in Lueneburg. That is what we could judge as the earliest composing, that would have been at age fifteen. Plus he could have arranged music pieces, which he listened to, and optimized them. Certified is the beginning of his skills as a composer from his time, which he spent in Arnstadt. There in the year 1703 he created his work "Prelude and Fugue in C Major for organ".
In the year 1708 Johann Sebastian Bach composed the first piece, which counts to the very famous ones by name, so that is to say among the works "which you have heard of before". That was the Town Council Inauguration Cantata with the name "God is my Lord". For the Bach Connoisseurs it's number 71 in the BWV.