The only way to treat an onychophosis is by either removing the cause or removing the symptoms:
Treat the symptoms:
Here you need a podiatrist to debride the callus that forms down in the nail groove and file the nail back from the painful area. This is almost too hard to do yourself.
Make sure the shoes are wide enough to not push on the painful area.
This can often recur and may need to be done periodically to relieve the symptoms.
Remove the cause:
As onychophosis is almost always due to the edge of a curved nail pushing on the nail groove then an option is a minor surgical procedure to remove the problem edge of the nail that is causing the problem. This is usually done under a local anesthetic.