Then when he says for God is my witness, he shows his affection for them from the prayer he offers for them. And because the business of prayer is carried on in secret in God's presence: when you pray, go into your room and shut the door and pray to your Father in secret (Matt 6:6), he calls on God to testify that he prays for them. First, therefore, he calls on the witness; second he shows on what point he calls the witness.
He calls on the witness when he says God is my witness under whose witness all things are done: I am judge and witness (Jer 29:23). Then, to show that he is not mistaken... in calling on the just witness, he mentions how he is joined to him. First, in regard to service when he says whom I serve, namely, with the worship of latria: the Lord your God shall you adore and him alone shall you serve (Deut 6:13). Second, in regard to the way he served when he says, in my spirit. As if to say: not only in outward bodily service, but especially within, according to the spirit: God is spirit, and those who worship him must worship in spirit and truth (John 4:24). Or in spirit, i.e., in spiritual observances, not in carnal, as the Jews: we are the true circumcision who worship God in spirit (Phil 3:3). Third, in regard to the office in which he serves, namely, in the Gospel of his Son: separated unto the Gospel (Rom 1:1). It is the Gospel of the Son in three ways: first, because it is about him: I bring you good news of a great joy (Luke 2:10). Second, because it was preached by him as a special duty: I must preach the good news of the kingdom of God to the other cities also, for I was sent for this purpose (Luke 4:43). Third, because it was enjoined by him: preach the Gospel to every creature (Mark 16:15).
But since, as Augustine says, it is the same to say for God is my witness and I swear by God, the Apostle seems to be acting against the Lord's command: I say to you, do not swear at all (Matt 5:34); above all, my brethren, do not swear (Jas 5:12). However, as Augustine also says, the meaning of Sacred Scripture is gathered from the actions of the saints. For it is the same Spirit who inspired the Sacred Scriptures: men moved by the Holy Spirit spoke from God (2 Pet 1:21) and who moves holy men to act: all who are led by the Spirit are sons of God (Rom 8:14).
Consequently, if Paul is found to swear, it shows that the Lord's word and that of the apostle James are not to be understood as indicating that an oath is absolutely unlawful, but that men should strive as far as possible not to use oaths as though they were something good and desirable of their very nature. And this on account of the danger involved in frequent swearing, namely, the possibility of perjury due to a slip of the tongue. Ecclesiastes says, do not accustom your mouth to oaths for many are tripped by them (Sir 23:9). Also because it seems contrary to the reverence we owe God for one to call God as witness without necessity. Hence: let not the naming of God be usual in your mouth (Sir 23:10). For this reason the Apostle never made an oath except in writing, when a man speaks with greater deliberation and caution.
Yet an oath is sometimes necessary to lend credence to a speaker, which in turn often benefits the hearer. Consequently, the Apostle makes an oath for the benefit of his hearer, for whom it was beneficial to believe, as though not seeking what was useful to himself but to the majority, namely, their salvation.
Hence, the Lord's statement that anything more than this, i.e., than a simple word, comes from evil (Matt 5:37) does not imply that it comes from evil in the one who swears, but in the one who demands the oath: it comes not from the evil of sin, except in the case where a person judges that the one from whom he demands the oath will swear falsely—in which case it is a serious sin, as Augustine says. Rather, it implies that it comes from the evil of punishment, i.e., our ignorance of whether something said to us is true.
It should be noted that there are two ways of making an oath: one is by a simple statement, as when it is said by God or God is my witness. This is the form the Apostle uses here. The other is by an imprecation, namely, when a person calls on God's witness in the form of some punishment to be inflicted on the speaker if he is lying: if I have requited evil with evil (Ps 7:3ff.). The Apostle also uses this form, as in 2 Corinthians: I call God to witness against my life (2 Cor 1:23).
Source: Commentary on Romans