A tooth can get infected by bacteria if a decay is not caught in time, if a leaky filling or damage in the tooth caused by trauma; toothache is always associated.
The only way of saving the tooth in this stage is Root Canal Treatment. It is a delicate procedure but it is not painful and might need more than one visit. 
RCT presuposes removing the bacteria and disinfecting the canal system.