I don't know if it's legally plagiarism but generally speaking.. if you have to ask, then it generally is because you know it's wrong. All you are really doing is changing someone else's song.. it's a cover song.. to call it your own would be plagiarism because you knowingly took pieces of the song and incorporated into your own. The same is true if you start writing the song and then realise it is already a well known song.. even if it's by accident.. you know when it's too close to a song because you just "know it".