I have had ankle pain for awhile. They feel like they need to pop and do constantly and they hurt most of the time. Could I need surgery?

BOTH? You mention 'they', so it's both? In addition to a musculoskeltal reason, maybe rheumatologic etiology should also be considered.
Possible. Chronic ankle pain might just need an exercise program but you could also have loose pieces or something could benefit from surgery.