I am on Gabapentin, Tramadol and Codeine for osteoarthitic hip pain and will be having surgery in 2 weeks. How do I wean off all this afterwards?

Discuss w/ surgeon. Be sure to get detailed directions from your surgery team about this important issue. Be sure you understand it well and ask for instructions for contact help if you discover further questions or problems. You are wise to want to plan ahead. They are the best source of guidance as they should know both your Hx and Tx most completely.