Before mentioning the title of the book or song, you would say "a":
- X wrote a book.
The title (which defines the book) is only added afterwards:
- X wrote a book entitled "YYY."
- "YYY," the book written by X, was published last year.
The same happens with similar noun phrases:
- When I was at school I had a friend called John.
- He married a young woman called Jane.