For finding out harmony, and modulations, the circle of fifths is always a great way to find harmonic changes of modulations.
Writing a good theme..... no. It's making a good theme. It is practically impossible to start composing a good theme without actually hearing it first. Most of the themes in my compositions come from what I hummed when walking in the street, or plainly studying. (Yes. I hum things I never heard before) Noodling on the piano also helps generate themes.
You can tell what is a good theme just by hearing it, a human instinct. When I hear a good theme from humming or noodling, I write it down ASAP, on paper usually. Try to build off there.
And for the variations, that Db in the second ending of the minor variation, is already well suited for a change. You said you wanted to write a 'short coda', but I think that you can add a few more variations after this minor key one. (But it's your composition. You can continue how you want) From there, what depends is what you want to do next.
If diving into a coda, I would write the coda first, then see how you can transition from where you left off to the coda.
If wanting to write a few more variations, I would either:
1. Disregard the second ending, and jump to the next one. This creates a surprising and returning tone.
2:Make a transition from where you left off, resolving back to the major key (A good way is to change the Db into a d natural in the next measure, then go the V-I [dominant-tonic] into F major)