How to stop being a B****

No one has actually called me one but I can admit that I have a bad attitude and at times can act like a B. Especially to my hubby and I hate it and I know it drives him crazy. 
It's just a lot of the small things like me being snappy or getting smart with him for small stuff and j don't catch it until afterwards and I can only apologize so many times before he thinks I'm BS-ing
How can I stop this (yikes)