Being accused of plagiarism carries serious penalties. In a work setting it can lead to losing your job, and in an academic setting it can lead to expulsion. If you have not plagiarised, then proving this can be difficult, although it is possible. You should fight to clear your name, as your reputation will be damaged and your integrity challenged. If you are guilty of plagiarism, then confession is always the best option.
Confess to your teacher if you did plagiarise, intentionally or accidentally, and explain why you did it. Although this will not get you out of trouble, it will show you are prepared to admit your mistakes and may get you a second chance at the essay. If you are guilty, you will be found out eventually, so confessing earlier may gain you clemency and will end a difficult and traumatic process.
Find out from the teacher specifically what you are accused of. If you are being accused of plagiarising a whole paper, and you did not, there will be an explanation, such as someone stealing your work and handing it in, or a malfunction in the plagiarism software. Do not confess to anything you did not do.
Review your sources and cross-reference what you wrote to see how similar it is. It may be that you accidentally copied down a sentence in your notes that you then put directly into your work. Show the teacher your notes, and explain where you cited other authors elsewhere.
Bring your notes and any other drafts into the teacher. Often accidental plagiarism or genuine coincidence is proved in this manner. If your drafts have the sentence cited, then this will prove it is an accident, particularly if you have the notes you made from the book.
Defend your cause if the teacher does not believe you and you have, through coincidence, given a sentence identical to someone else's. This does happen, however rarely. In these circumstances, your lack of prior conviction for plagiarism will work in your favour. If you have not plagiarised, say so, however suspicious you feel you look. If you confess to something you haven't done, you are as guilty as if you had, and will be punished as if you have.