Would the vedic hymns count as music?
While I cannot speak to the oldest piece of music ever created, I can tell you that the oldest national anthem is Het Wilhelmus, the national anthem of the Netherlands.
It dates from 1574, it was very popular when it emerged and eventually came to serve as the official anthem of the House of Oranje.
We do not know who wrote it, there are three theories about the identity of the writer. The first is that it was written by Phillips of Marnix, the lord of Saint-Aldegonde who was a prodigious writer in his time. The second is that it was written by Theodore Cornhert, a Dutch theologian and the father of the Dutch renaissance. The third is that it was written by an unknown author, some Dutchman who wrote the song and never claimed it as his own. The third theory is more likely as neither of the named possible authors ever claimed the song as their own in spite of its huge popularity.
Some people think that the oldest national anthem is Kimigayo, the national anthem of Japan. The words of the song are indeed far older than the Wilhelmus but they were never put to song until the 1860s. Wilhelmus on the other hand, has always been a song.