How long can narcotic pain medication get stuck in your system?

It Depends. The answer is specific to the drug(s) involved, your general medical profile including the states of your liver and kidney functions, length of use, dosage, etc. If your question is more than for general information or curiosity, please consult with your pcp.
Opioid medication. Opioids really do not get stuck in your system. Almost all medication are removed by metabolism. This is different from one to another. Many other factors also play a role - liver function, kidney function, othe medications that may compete for the same pathways, -- every person is different.