I know the question is about grain direction and this may be obvious, but it's safer to plane over the edges from the outside towards the center of the piece. This avoids breakout. It can be a good idea to use a sacrificial piece, or by chamfering the edges before planing endgrain.
Assuming that edge breakout can be eliminated, if the direction of grain is orthogonal to the sole of the plane (perfectly 90degree to the sole of the plane in X/Y) then the direction of planing doesn't matter so much. If the grain tilts one way or another, then the more the the grain is oriented towards the direction you move the blade to, the smoother the cut will be.
As mentioned in this comment, you should find that a very sharp iron cuts finely regardless of direction. But even in cases where sharpening skill or equipment (or patience) doesn't produce a plane iron that is laser-sharp, I've found that skewing the plane (i.e. at a non-90degree attack angle, e.g., moving the plane body Northwards, while keeping the plane pointed NE or NW) always seems to leave a smoother endgrain surface.
edit: added skewing reference. thank you.