It depends on the narcotic. Even various "pain medications" take different times. I'd say a month is about the longest anything would stay in your system assuming you didn't do enough of it to kill an elephant.
If the pain medicine was prescribed to you, you have nothing to worry about. If it shows up after doing your drug test show the script to your employer. If the the narcotics was not yours and you only took it once it will be out of your system in 24 hours.