Have you ever written a book?

Literal

Book [object-を] wrote [experience-ことがある]-[polite]-[question-か]?

~たことがある ('have done before') is the standard experiential perfect in Japanese, using the past form of a verb + ことがある. Not to be confused with ~ことがある (dictionary-form + ことがある), which means 'there are times when / may sometimes.' The polite version ~ことがありますか asks about experience.