The Church teaching:
TAKING THE NAME OF THE LORD IN VAIN
CCC 2150 The second commandment forbids false oaths. Taking an oath or swearing is to take God as witness to what one affirms. It is to invoke the divine truthfulness as a pledge of one’s own truthfulness. An oath engages the Lord’s name. “You shall fear the LORD your God; you shall serve him, and swear by his name.”
CCC 2151 Rejection of false oaths is a duty toward God. As Creator and Lord, God is the norm of all truth. Human speech is either in accord with or in opposition to God who is Truth itself. When it is truthful and legitimate, an oath highlights the relationship of human speech with God’s truth. A false oath calls on God to be witness to a lie.
CCC 2152 A person commits perjury when he makes a promise under oath with no intention of keeping it, or when after promising on oath he does not keep it. Perjury is a grave lack of respect for the Lord of all speech. Pledging oneself by oath to commit an evil deed is contrary to the holiness of the divine name.
CCC 2153 In the Sermon on the Mount, Jesus explained the second commandment: “You have heard that it was said to the men of old, ‘You shall not swear falsely, but shall perform to the Lord what you have sworn.’ But I say to you, Do not swear at all. . . . Let what you say be simply ‘Yes’ or ‘No’; anything more than this comes from the evil one.” Jesus teaches that every oath involves a reference to God and that God’s presence and his truth must be honored in all speech. Discretion in calling upon God is allied with a respectful awareness of his presence, which all our assertions either witness to or mock.
CCC 2154 Following St. Paul, the tradition of the Church has understood Jesus’ words as not excluding oaths made for grave and right reasons (for example, in court). “An oath, that is the invocation of the divine name as a witness to truth, cannot be taken unless in truth, in judgment, and in justice.”
CCC 2155 The holiness of the divine name demands that we neither use it for trivial matters, nor take an oath which on the basis of the circumstances could be interpreted as approval of an authority unjustly requiring it. When an oath is required by illegitimate civil authorities, it may be refused. It must be refused when it is required for purposes contrary to the dignity of persons or to ecclesial communion.