Believe it or not what you are experiencing is very common and often done unconsciously without you even realizing what you are doing. Chord progressions cannot be copyrighted because there are only a certain number of common chords that fit in a given key. You might have seen the Axis of Awesome video where they demonstrate that the same chord progression is found in hundreds of songs.
But subconsciously - a given chord progression may suggest a particular melody that you have heard before and you end up composing a song that ends up with a melody that sounds very much like a copyrighted work.
When that happens to me I find that the most effective way to arrive at a new melody, is to make a minor change to the chord progression. Perhaps I will throw in a fourth chord if my verse progression has only three chords. Or change the order of two of the chords. Either of these changes will usually take your melody on a detour (different direction) from where you started and you end up with a unique melody.
If I really don't want to change my chord progression, I might reverse the order of some of the melody notes or jump an octave between lines of the verse as it leads into the chorus.
If I'm still hearing another copyrighted song in my melody after making the changes suggested above, I might try adding a bridge or key change to further differentiate my composition from the one that subconsciously manifested in my original melody.
Disclaimer - none of anything I say is to be construed as legal advice. I personally try to be sure I'm not accused by a listener of copying the melody of another artists work. But I don't worry too much about it either - because none of my songs are a blatant attempt to copy some other song. But I am sure some portions of some of the melodies I have composed are going to sound like something someone has heard before. With thousands of song melodies dancing around in my subconscious - it's simply unavoidable.
Good luck and have fun with your composing.