The second sentence is ungrammatical. The first is grammatical, but the double "had" sounds a little awkward. In the US you might say simply: How long after you had the surgery did it start to hurt again?
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.