You can take any painkiller, as long as it is prescribed and you don't abuse it. I'd advise you get off of it as soon as your tooth is better because the stuff can be addictive.
Some people in AA consider this a sobriety violation, I don't. If you were doing recreationally - just taking pills to "zone out", that is different and would be a break in your sobriety, IMHO.