Take until pain subsides.
It is safe to take for extended periods, but likely your doctor did not intend for you to be on it for life. Watch for signs of stomach irritation or upset. If this develops, then stop the med. If you take it regularly for more then a year, have annual blood tests to monitor your kidneys and liver. Just like many long term meds, these can start to affect your organs.