If you use nigger out of anger or frustration I had a similar problem. What worked for me was just channeling that stress and anger into something else other than words. Usually I drew something on a paper, wrote something, gripped something with my hand, punched the wall, just screaming (usually where people can't hear me) , etc.
If you use nigger as a casual slur, like jokingly calling you friend a faggot or gay. For me it was just a matter of stoping myself before saying a slur and just saying something less offensive like retard or fucker.