In The Wolverine, it seems Logan killed Jean by accident in his sleep, but then he said something along: it had to be done...
What was the story between these two? (and in which movie did it happen if at all?)
There have been a number of X-Men films before The Wolverine. In particular X-Men (2000), X2 (2003) and X-Men: The Last Stand (2006) feature Jean Grey and Logan's relationship. Her death at his hands (claws) occurs in the latter of these.
When Jean come back in The Last Stand as the Phoenix, after apparently drowning at the end of X2, and starts destroying the world, Wolverine is the only available mutant who has any chance of stopping her, due to his healing factor. In the finale of the film, he stabs her through the heart.