Well first of all, it is wrong to swear/promise at any time for anything. You cant just get angry or excited to something and start swearing right away without thinking.
So you should not swear unless you have to and you have to keep your swear/promise if you said it. But if you swore to do a sin or anything wrong then you can break your swear/promise and pay your penalty. The penalty here would be giving 10 fitr to 10 different poor people.
For example if you swore on not talking to somebody or not going back home or etc. You can break those words and go back to your home or start talking to that person.