Great question. The prohibition against taking the Lord's name in vain is recorded in Exodus 20:7 and is included in the 10 Commandments. It says:
“You shall not take the name of the LORD your God in vain, for the LORD will not hold him guiltless who takes his name in vain." (ESV)
To fully understand this commandment we need to realize that God's Name is so much more than just a title. The name of God is a declaration of His very being and character. So to use His name is is to speak of who He is. (Remember, when God passed by Moses who was hidden in the cleft of the rock, it says that God "proclaimed the name of the Lord." See Exodus 33) That means God literally proclaimed His character to Moses.
The word "vain" essentially means empty or meaningless. So we take God's name 'in vain' when we use His name is an empty or meaningless way. Even an expression like, "Oh my God!" falls under this kind of use.
When I was a kid, taking the Lord's name in vain meant using God's name as a curse word. And no doubt that's included in the prohibition, but for the Jews it was connected to swearing a vow in the name of the Lord in an insincere or hypocritical manner. To make a vow invoking the Lord's name, and then to not keep that vow was considered taking the Lord's name in vain. That's not something that happens much in our culture today.
The bottom line is that when we use God's name it ought to be for either prayer, praise or personal sharing and it should always be spoken with respect and honor. In other words, our speech should reflect our heart toward God.