I don't believe Paul is swearing to God in this verse. It seems Paul is using God as verification that what Paul says is true. This definitely implies Paul is swearing to God, but I don't think the swear is directed towards God; it's directed towards the men Paul speaks to. Paul is claiming God has witnessed and verifies Paul's word is true. In English, this would be considered the equivalent to the idiom of "I swear to God", but I don't think the language allows for a direct swear towards God.
Paul is saying God can witness and testify that what Paul says is true. So rather than "I swear to God", Paul is saying "I swear to you that if I'm lying, God is also lying". The Greek word for witness is μάρτυς G3144.
"He is said to be a witness, to whose attestation appeal is made;
hence, the formulas μάρτυς μου ἐστιν ὁ Θεός, Romans 1:9 (Paul);
Philippians 1:8 (Paul); Θεός μάρτυς, 1 Thessalonians 2:5
(Paul): μάρτυρα τόν Θεόν ἐπικαλοῦμαι, 2 Corinthians 1:23
(Paul); ὑμεῖς μάρτυρες καί ὁ Θεός, 1 Thessalonians 2:10
(Paul)"
To "swear to God" is to make a promise towards God that you will do or you have done something. If you swear to do something, you are obligated to do it. If you swear you've done something, then you are either lying or telling the truth.
Like if someone said...
"Now the things which I write unto you, behold, before (ἐνώπιον: before the face of, in the presence of) God, I lie not." Galatians 1:20
b. metaphorically: πίστιν ἔχε ἐνώπιον τοῦ Θεοῦ, have faith satisfied
with this that it is not hidden from the sight of God, Romans 14:22;
ἁμαρτάνειν ἐνώπιον τίνος (see ἁμαρτάνω at the end), Luke 15:18, 21;
especially in affirmations, oaths, adjurations: ἐνώπιον τοῦ Θεοῦ, τοῦ κυρίου, etc., Galatians 1:20 (Paul); 1 Timothy 5:21
(Paul); 1 Timothy 6:13 (Paul); 2 Timothy 2:14 (Paul); 2
Timothy 4:1 (Paul). Hence, those are said to do something in the
presence of one who have him present to their thought, who set him
before their mind's eye: προωρώμην (πρωρωμην L T Tr WH) τόν κύριον
ἐνώπιον μου, Acts 2:25; ταπεινοῦσθαι ἐνώπιον τοῦ κυρίου, James 4:10
(Sir. 2:17).
That would be swearing to God. If you're lying, then you're lying directly towards God. Here, Paul is saying "in front of you and in front of God, I'm telling the truth". (The thing that Paul is talking about here can be comfirmed at Acts 9:?.)
This is why Yeshua does not advise us to make any vows...
"Again, ye have heard that it hath been said by them of old time, Thou shalt not forswear thyself, but shalt perform unto the Lord thine oaths:
But I say unto you, Swear not at all; neither by heaven; for it is God's throne:
Nor by the earth; for it is his footstool: neither by Jerusalem; for it is the city of the great King.
Neither shalt thou swear by thy head, because thou canst not make one hair white or black.
But let your communication be, Yea, yea; Nay, nay: for whatsoever is more than these cometh of evil." Matthew 5:33
I hope that clears it up. Thank you.