Someone has asserted a wrong statement about me, which I have never done in my life. They were trying to punish me, even though I was innocent. So I swear by Quran in front of them they knew that they were wrong. I am wanting to know that, have I done right? Will Allah punish me for it?
There is no sin in that you have sworn on the authority of Allah to prove your innocence. Source. But you should not have sworn on Quran, but on Allah Himself.
For the sake of completion, I must add that one may only swear on Allah, not anything or anyone else.
However, IslamQA gives a little elaboration on swearing on Quran as follows:
As for swearing on the Mushaf, if what is meant is the words of Allaah contained therein, then it is an Islamically acceptable oath;
but if what is meant is the paper and ink, then it is an oath by something other than Allah, which is shirk
Hence it is better not to swear by the Mushaf