In "God's Word for Today" David Woods writes:

Psalm 40 has two quite distinct parts. Verses 1-10 are a thanksgiving Psalm; verses 11-17 are an individual lament. The NIV Study Bible draws this conclusion: “The message is that even when God answers prayer and provides relief, there will usually come a new crisis that forces a return to God as one's refuge and deliverer.”

Source: Studies in the Psalms: Adult Teacher's Insights, page 34.