"When was this book written?"
Translation:Kiedy została napisana ta książka?
Yes, I can't think of any exception, though using "był/a" instead of "został/a" feels a bit more colloquial to me.
I left out the "została", but the correct answer was given as "Kiedy napisano tę książkę?" Is that an acceptable alternative?
It's quite different grammatically, but perfectly correct.
Generally, you can't leave out "została", because then you arrive at "Kiedy ta książka napisana" which would be like "When this book written".
"Kiedy napisano tę książkę" uses a completely impersonal form, so there is no real subject, but it's quite a common construction. It just works like "When X happened"... only that X is not the subject.