Just an addendum for extra clarity
A good format to use by way of example is movies and books. You'll see a lot of movies out there that are based on books or comics. All those X-Men movies, or Memoirs of a Geisha (first things I could think of, seriously brain?). The point of basing anything on something else, is that you generally are following lines already laid down. For instance, making a book into a screenplay usually requires sticking to the overall plot and character development. Harry Potter and the Game of Thrones tv show are both based on books already written.
I'd like to point out that movies "based on" books are called "adaptations". At least, the examples you cited are. They take the source materials (the books) and translate them into a new medium (movies). Their aim is to copy the original resource into a new form, although they often make changes for marketing purposes (ie: to widen the demographic or increase ticket sales)
A better example of a movie "based on" a book rather than adapting the book into film form might be Tangled, which uses the fairy tale of Rapunzel as a base. Very generalized, they're about the same thing. A girl with incredibly long hair is trapped in a tower by a wicked witch, until she is rescued by a handsome prince. But there are differences; instead of poor farmers who couldn't have children, Rapunzel's parents in Tangled were royalty. Instead of kidnapping Rapunzel because she was promised in return for the ability to have children, in Tangled Rapunzel was kidnapped because her hair is magic! Like most old fairy tales, the book version had a more gruesome ending, too. However, despite its many differences, you can see the resemblance between Tangled and Rapunzel, because Tangled is "based on" it.
Another way to define "inspired by" would be "got the idea from".
The definition of "inspired" means "of such extraordinary quality, as if arising from an external creative impulse", so we can define any idea that was born from other ideas "inspired", technically speaking.
With the Harry Potter example you've given, I'd say it's "based on" if it takes place in JK rowling's world, because it's importing elements from the original instead of taking the ideas behind it and coming up with its own thing. Fan-fiction in general, even AU fanfic and Genderswapped fanfic, is "based on", because by definition it uses material directly from the original source; even if the material is tweaked a bit.
If someone were inspired by the Weasley's joke shop, and wrote an original story about two magicians who operate a shop of magical jokes, set with their own characters, their own joke items, and their own universe, THAT would be "inspired by" the Weasley's joke shop in Harry Potter
If someone were inspired by the relationship between Harry, Ron, and Hermione, and wrote their own story about three friends who struggle in a weird love triangle, but was not about wizards, magical schools, etc (ie; they just used this idea and wrote their own story), that would be "Inspired by" Harry potter.
In summation:
Think of "based on/off" as being something that takes the original
material and does something new with it, such as fan fiction, Tangled, etc. Fiction "based on/off" other fiction makes greater use of the
material from its source, without plagiarizing it
Think of "Inspired by" as meaning that the
idea came from a different source, but the
material is the creator's own.