In order to optimize your overhead press grip, you want to make sure of two things: optimal grip width and proper hand placement.
Grip Width
The optimal grip width is going to vary from person to person. However, it should ALWAYS create a vertical forearm at the bottom of the press. This will maximize the mechanical efficiency of the lift and allow you to lift the most weight possible.
If you grip it too wide or too narrow, you'll limit the amount of weight you can press; however, you should ultimately do what feels best, especially if you have a history of shoulder pain.
Sometimes a slightly wider grip will feel better on your shoulders, and sometimes a more narrow grip will feel better. Ultimately, what you're doing here, is manipulating the degree of shoulder abduction to find that "sweet spot" that feels best. If you're dealing with shoulder pain during th bench press, check out this article.
Where to Grip the Barbell in Your Hand
In order to promote a neutral wrist and optimal overhead press, you want to grab the bar in the fleshy, meaty part of your hand close to your thumb. This will limit any moment arm from the bar to your forearm and maximize the efficiency of the lift.
If you grip the bar like the picture on the left (above), you now create a moment arm from your forearm to the bar, which makes the lift more difficult. Additionally, this will encourage you to press with extended wrists, something that you also don't want to do!
For more information on how to maximize your overhead press grip, check out the video below!