My understanding is that the passage quoted does not forbid all oaths in general, but in specific was addressing the practice of the Scribes and Pharisees, who were invoking the name of God, or heaven in their oaths, and breaking them. I don't see myself where the Scribes or Pharisees are mentioned specifically.
I'd have to study it out further, but I do believe that he was teaching based on a general lack of reverence for the name of God. Taking an oath made in God's name is serious, which is why Jesus warned us to let our yes be yes and our no be no. It is better not to swear on the name of God than to swear and break it.
There's an excellent article on this here: http://www.reformed.org/webfiles/antithesis/index.html?mainframe=/webfiles/antithesis/v1n1/ant_v1n1_oaths.html
In it, the author explains how and why this applied to the Scribes and Pharisees, not to all oaths in general.
It goes on to cite scriptures in the bible where we are expected, and even commanded to swear oaths in the name of God in certain occasions.
The following is a small excerpt from the articles, where this is explained, with scripture references:
The general context of Scripture, when studied carefully, reveals that
God does not forbid all oaths.
First, Scripture commands us to swear by the name of God on certain
occasions. In Deuteronomy 6:13, for example, Scripture commands God's
people "You shall fear only the Lord your God; and you shall worship
Him, and swear by His name." Far from prohibiting all oaths, Isaiah
tells us that "he who swears in the earth shall swear by the name of
God" (Is. 65:16). God sanctions lawful oaths to such an extent that He
promises to build up those who swear by His name (Jer. 12:16). Even in
the mundane affairs of life, such as confirming the truth between
disputing neighbors, God commands His people to swear before Him (Ex.
22:10-11). Because Scripture commands God's people to swear by His
name, it cannot forbid all oaths. God does not command what He
Second, Scripture also teaches us that swearing is an act of
confession and religious worship. We already saw in Deuteronomy 6:13
that God commands us to swear in His name precisely because swearing
in God's name is but one way to worship and fear Him (cf Deut.10:20).
Isaiah confirms this connection between swearing and worship; when he
prophesies about the Assyrians and Egyptians coming into a covenantal
relationship with God, he says that they will swear in the name of
God. (Is. 19:18). Calvin explains that "by swearing in the Lord's name
they will profess his religion."
But exactly how is swearing an act of confession and worship? When we
duly swear in God's name, we confess several things about God. To
begin with, we confess that God exists. Moreover, we confess several
of God's attributes as revealed to us in Scripture: we testify that He
is omnipresent and omniscient, that He is eternal and immutable, that
He is just and true, that He is powerful and wrathful. By confessing
His existence and attributes, we also confess that He is the Supreme
Judge over all the earth and that we are accountable to Him for all
that we do and say. Though the word of men may fail, the word of God
never fails. Though men may fail, God never fails. By taking oaths in
God's name, we confess God to be the ultimate arbiter of truth, and we
worship the God of truth in spirit and in truth.
Finally, in the context of swearing in in court, or an oath of office, the practice started when more people understood and respected the gravity of swearing such an oath. It was meant to be binding.
They believed, correctly, that an oath sworn in God's name should carry more weight, and that it is a serious thing to break it. Whether or not people still see it that way, or if we're merely repeating words these days, is open to debate, and likely as individual as those taking the oaths.