Hammertoes are gradual deformities of the toes that generally evolve because of wearing shoes that are too tight. Therefore, as you already suggest, the primarily treatment is to wear shoes that fit well.
If you do not have a history of wearing tight shoes, then you should probably see your primary care doctor
. This is because the other common cause of hammertoes is a neurological problem in the feet. This commonly is also coupled with pes cavus, or high arches. What happens in this situation is that the small nerves to the muscles in the feet do not work well, leading to gradual deformity of the feet. There are many conditions that can cause this, but the most common is probably an inherited nerve condition known as Charcot Marie Tooth.
Treatment for hammertoes generally is supportive, meaning wearing good shoes. In more severe cases, where the toes are rubbing, you may need to have a pair of orthotics shoes specially made for your feet. Stretching exercises and physical therapy may also help. In the more extreme cases, you made need surgery
on the toes to correct the deformity.
I would start by talking with your primary care doctor or your podiatrist