Which sentence is gramatically correct?

1) What did Karen tell him to do after she heard his story?

2) What did Karen tell him to do after she had heard his story?

I think "had" isn't necessary.
Both are correct. The first is a simplified version, made possible by the presence of "after," which clarifies the sequence.
The first sentence is grammatically correct because the word 'after' in the sentence indicates that the speaker is talking about a list of events happening in chronological order....the past perfect is used when you speak about something that happened in the past and then you MOVE BACK IN TIME to speak about something which happened BEFORE!

Teachers: We supply a list of EFL job vacancies
Dear Bernice,

Thank you for your reply.

It helps!

 Marius Hancu's reply was promoted to an answer.