The phrase is 'dang it'. Originally, it was a mild way of saying 'damn it'. Used today, it's no longer considered vulgar or profane. Even a very religious person who avoids all profanity might still say 'dang it'.
I would say you're safe to use it in just about anyplace. Very few people today would consider it offensive. It's actually become kind of amusing.
Student or Learner