You can give the entity a tag and use an execute-command to test if it is in the range.
execute as @p at @s unless entity @e[tag=your_tag,distance=..10] run tp @e[tag=your_tag] @s
With your setup, it won't teleport any entities if they are within 10 blocks. Also it's teleporting the player to themself every tick, which gets annoying pretty fast.
Try an always active, unconditional, repeating command block with the command
/execute as @a[name=username] at @s run tp @e[distance=0.01..10] @s
This will teleport any entities within a 10 block radius, excluding yourself, to you. This way you aren't constantly teleported to yourself, but any entities that enter within 10 blocks of you will be. Obviously, if you want a specific entity to teleport to you, which I'm assuming you do, then add the data tag or name of the entity with tag= or name=
With this command in a repeating command block a entity further away than 10 blocks with the tag "your_tag" is teleported to you.
This assumes, you only have one entity. If you have more entitys this command would be better:
execute as <username> at @s run tp @e[tag=your_tag,distance=10..] ~ ~ ~
You can write "as username" instead of "as @a[name=username]. Aside from this the command is ok but i think the goal is not to tp every entity within a range of 10 to the player every tick.
I tried your command and it didn't work, that's why I posted another solution. Thanks for the feedback on my command, I didn't realize that OP wanted it when an entity exits the range rather than enter. Good luck with your coding!