Excellent question. The boundaries between different forms of derivative work are constantly being pushed and redefined. "Derivative" has come to be used mostly as an insult, but as you rightly point out, some works of fiction (I would argue 'most works') draw inspiration from preexisting sources. In a way, storytelling is an ongoing cultural endeavour.
But you didn't come here for a spiel about the collective unconscious, right? Let's get to the meat of it.
Your story contains derivative elements, and these elements are deliberate. You've established that much. You admire this story that you've read, something about it has touched you and you want to replicate that experience, but also to personalize it. Stop me if I'm missing the mark. What you struggle with is how to balance which elements to change, and which to keep. You want your story to be readily recognizable as an extension of the literary tradition in which these previous stories have been written, but still to stand on its own.
There are two things you absolutely need to do. I'm going to try and make this as generally applicable as possible. Number one, you need to identify the compelling element that draws you to the story. What is the focus of your interest? This can be difficult to identify, and requires a fair bit of practice, at least in my experience. If you're stumped, try writing freeform stream-of-consciousness about why you like your favorite story and why you keep coming back to it. Say, for twenty minutes. Once you've identified the heart of the story -- in your own subjective experience -- you know more about what can be dropped (e.g. 'kid wizard in glasses') vs. what definitely needs to be kept (e.g. 'choice is more important than destiny').
The second thing you need to do is background reading. Lauren touched on that above, but I'd like to generalize it even more. The Hero's Journey is never not useful, but you might like to zoom in more closely on the specific tropes and elements you want. When transitioning from a reader to a writer (or from a consumer to a creator), your best step is to figure out who inspired the people who inspire you. This is where you might start to feel like you're telling just one chapter in a longer story. At least, that's how I usually feel. You don't have to become a scholar, but you need some familiarity with the timelessness of the ideas you're playing with.
Mythology, folklore and fairy tales are invaluable. It's invaluable to recognize that older forms of storytelling -- up until fairly recently -- invariably involve dozens of variations on the same basic story. There is no writer who can't learn something from myth and folklore. You don't need to know every story, and you can't know every story. The point is to grasp the principle behind it. This is why fairy tales are so useful, because they demonstrate far better than modern novels the myriad forms in which a core idea can be developed. There is nothing new under the sun. That's not a bad thing. Your story is in no way less important or valuable than the ones that came before it. You just need to find what story it is you're trying to tell, and what it is that you, specifically (and no one but you) can bring to it.