How should I approach the editor if I have been omitted from the author list of a paper I contributed to? As I left my PhD in between, my name has not been put in the published paper. My PI published  the paper in a very clever way. I worked in the entire project and it was a team work. he put all the names who are involved except mine. 

How should I approach the editor as I deserve an authorship? And one of the editors of that journal was our departmental head and his name was there in the paper.

Kindly let me know about your suggestion.
You need to be very careful. It sounds like you are accusing your former PI of academic misconduct. Even if he committed misconduct, things can (and will) likely get messy fast.

Normally, I would only recommend approaching the editor after other avenues have been explored. For the case where the editor is an author and your former department head, it is going to be hard to avoid the editor. I would suggest you contact all the authors on the paper (this includes the editor/department head) and tell them you were surprised you were not an author. They will hopefully be able to clear up the misunderstanding. Potentially, they forgot to list you as an author, although that seems unlikely, and are willing to contact the journal to get you added. Alternatively, they decided your contribution did not warrant authorship.

If they do not think you deserve authorship, it is best to get their side of the story first. Maybe they recollected all your data and redid all the research that you were involved in, in which case your claims for authorship are weaker. Maybe their argument is that while your data and analysis are included, they do not think it was enough for authorship. Once they tell you their side of the story, if you still think you should be an author tell them why.

If you cannot resolve the authorship issue as a group, then you need to bring in your head of department. In your case, he will be aware of the issues, since he is also an author. Once you raise a formal complaint, he will hopefully hand it off to an independent person (e.g ., the head of a different department).

If the university cannot help you reach an agreement, then you need to approach the journal. Again, in your case the journal will likely be aware of the issue because the author is the editor. Hopefully, the issue will be handed off to an independent editor from the journal.

If you cannot get an independent person from your university or the journal, or you cannot reach an agreement regarding authorship, then you may want to contact COPE.