Various creeds and confessions can be utilized in answering a question like this one. A general view has been that Jesus is denouncing or correcting actions that were abusing oaths and the inherent trust meant to be attached to them.
We should also take note of James's teaching in James 5:12 (ESV):
But above all, my brothers, do not swear, either by ...
Disclaimer: I'm not a theologian or aware of what theologians have said on this matter. I am merely answering this based off the context of the scriptures.
So, if you look at Deuteronomy 6, you will find this passage (emphasis mine):
13 Thou shalt fear the Lord thy God, and serve him, and shalt swear by his name.
14 Ye shall not go after other gods, ...