After a fracture requiring casting (not surgery) the worst pain is usually only a few days to perhaps 2 weeks. Most of the pain is from the bones moving and by 1 – 2 weeks the bone starts to get “sticky” However swelling is a big issue with a fracture in the foot and ankle and swelling can cause pain itself (thinking of an elephant standing on your foot from the inside). This is one of the important reasons to keep the foot/ankle elevated after an injury. Swelling will decrease with time, but can even last beyond the healing of the fracture if you have been standing, walking, or exercising for a longer time.
Pain after surgery will follow a very similar course including the swelling.