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 heaven or by earth or by any other oath, but let your “yes” be yes and your “no” be no, so that you may not fall under condemnation.
From the WCF 22 (with American Revision for 22.3):
- A lawful oath is part of religious worship, (Deut. 10:20) wherein, upon just occasion, the person swearing solemnly calleth God
to witness what he asserteth, or promiseth, and to judge him according
to the truth or falsehood of what he sweareth. (Exod. 20:7, Lev.
19:12, 2 Cor. 1:23, 2 Chron. 6:22–23)
- The name of God only is that by which men ought to swear, and therein it is to be used with all holy fear and reverence. (Deut.
6:13) Therefore, to swear vainly, or rashly, by that glorious and
dreadful Name; or, to swear at all by any other thing, is sinful, and
to be abhorred. (Exod. 20:7, Jer. 5:7, Matt. 5:34, 37, James 5:12)
Yet, as in matters of weight and moment, an oath is warranted by the
Word of God, under the new testament as well as under the old; (Heb.
6:16, 2 Cor. 1:23, Isa. 65:16) so a lawful oath, being imposed by
lawful authority, in such matters, ought to be taken. (1 Kings 8:31,
Neh. 13:25, Ezra 10:5)
- Whosoever taketh an oath ought duly to consider the weightiness of so solemn an act, and therein to avouch nothing but
what he is fully persuaded is the truth: (Exod. 20:7, Jer. 4:2)
neither may any man bind himself by oath to any thing but what is good
and just, and what he believeth so to be, and what he is able and
resolved to perform. (Gen. 24:2–3, 5–6, 8–9)
- An oath is to be taken in the plain and common sense of the words, without equivocation, or mental reservation. (Jer. 4:2, Ps.
24:4) It cannot oblige to sin; but in any thing not sinful, being
taken, it binds to performance, although to a man’s own hurt. (1 Sam.
25:22, 32–34, Ps. 15:4) Nor is it to be violated, although made to
heretics, or infidels. (Ezek. 17:16, 18–19, Josh. 9:18–19, 2 Sam.
21:1)
- A vow is of the like nature with a promissory oath, and ought to be made with the like religious care, and to be performed
with the like faithfulness. (Isa. 19:21, Eccl. 5:4–6, Ps. 61:8, Ps.
66:13–14)
- It is not to be made to any creature, but to God alone: (Ps. 76:11, Jer. 44:25–26) and, that it may be accepted, it is to be made
voluntarily, out of faith, and conscience of duty, in way of
thankfulness for mercy received, or for the obtaining of what we want,
whereby we more strictly bind ourselves to necessary duties: or, to
other things, so far and so long as they may fitly conduce thereunto.
(Deut. 23:21–23, Ps. 50:14, Gen. 28:20–22, 1 Sam. 1:11, Ps. 66:13–14,
Ps. 132:2–5)
- No man may vow to do any thing forbidden in the Word of God, or what would hinder any duty therein commanded, or which is not in
his own power, and for the performance whereof he hath no promise of
ability from God. (Acts 23:12, 14, Mark 6:26, Numb. 30:5, 8, 12–13) In
which respects, popish monastical vows of perpetual single life,
professed poverty, and regular obedience, are so far from being
degrees of higher perfection, that they are superstitious and sinful
snares, in which no Christian may entangle himself. (Matt. 19:11–12, 1
Cor. 7:2, 9, Eph. 4:28, 1 Pet. 4:2, 1 Cor. 7:23)
The Westminster Confession of Faith (Oak Harbor, WA: Logos Research
Systems, Inc., 1996).
From the Heidelberg Catechism:
QUESTION 99. What is required in the third commandment?
ANSWER.
That we must not by cursing, or by false swearing, nor yet by
unnecessary oaths, profane or abuse the name of God; nor even by our
silence and connivance be partakers of these horrible sins in others;
and in sum, that we use the holy name of God no otherwise than with
fear and reverence, so that he may be rightly confessed and worshiped
by us, and be glorified in all our words and works.
Philip Schaff, The Creeds of Christendom, with a History and Critical Notes: The Evangelical Protestant Creeds, with Translations, vol. 3 (New York: Harper & Brothers, 1882), 343–344.
From the Thirty-Nine Articles of the Anglican Church
XXXIX Of a Christian Man’s Oath
As we confess that vain and rash Swearing is forbidden
Christian men by our Lord Jesus Christ, and James his Apostle, so we
judge, that Christian Religion doth not prohibit, but that a man may
swear when the Magistrate requireth, in a cause of faith and charity,
so it be done according to the Prophets’ teaching, in justice,
judgment, and truth.
Philip Schaff, The Creeds of Christendom, with a History and Critical
Notes: The Evangelical Protestant Creeds, with Translations, vol. 3
(New York: Harper & Brothers, 1882), 513–514.
Another helpful teaching can be found in J. I. Packer's Concise Theology:
(Note that he begins by citing Neh 5:12–13.)
Truth in relationships, especially between Christians, is divinely commanded (Eph. 4:25; Col. 3:9), and truth-telling is specified as integral to authentic godliness (Ps. 15:1–3)…
Oaths are solemn declarations that invoke God as a witness of one's statements and promises, inviting him to punish should one be lying. Scripture approves oath-taking as appropriate on solemn occasions (Gen. 24:1–9; Ezra 10:5; Neh. 5:12; cf. 2 Cor. 1:23; Heb. 6:13–17), though at the time of the Reformation the Anabaptists declined the practice as part of their rejection of involvement in the life of the secular world. They appeals to Jesus' condemnations of oaths devised and designed to deceive as if it were a rejection of oath-taking as such rather than a call for honest speech and a warning against the temptation to use words that give false impression, with manipulation and exploitation as one's real purpose (Matt. 5:33–37; cf. James 5:12).
Vows to God are the devotional equivalent of oaths and must be treated with equal seriousness (Deut. 21:23; Eccles. 5:4–6). What one swears or vows to do must at all costs be done (Ps. 15:4; cf. Josh. 9:15–18). God requires us to take seriously not only his words but our own as well. However, "no many may vow to do anything forbidden in the Word of God, or what would hinder any duty therein commanded" (Westminster Confession XXII.7).
J. I. Packer, Concise Theology: A Guide to Historic Christian Beliefs. (Carol Stream, IL: Tyndale House, 1993), 190–192.