Yeah! You can choose any subject as your optional and it doesn't matter which subject you have done graduation on. But you must have a reason why you are studying literature instead of Physics which you have taken as a subject in your UG. Such questions are oftenly asked in the Personality Test of UPSC CSE. So you can take the subject but you should give some time in thinking an accurate answer of choosing Literature as an optional and not physics.
To know more about UPSC CSE visit the link below:
https://competition.careers360.com/exams/upsc-civil-services-exam
I hope this answer helps. All the very best for your future endeavors!
Regular exam updates, QnA, Predictors, College Applications & E-books now on your Mobile