The best option is to declare the ball unplayable under Rule 28. The player has the option of declaring his ball unplayable anywhere on the course except in a water hazard.
Since you were so close to Out of Bounds, 28c is the best–drop a ball within two club lengths from where the ball lay under penalty of one stroke.
However, you could return to the spot from where the stroke was played (28a), or drop a ball keeping the point where the ball lay between you and the hole (28b), which doesn’t work well with the out of bounds so close.
I had a situation yesterday where my tee ball landed close to out of bounds. I hit a provisional ball. I found that my first ball landed inbounds but within nine inches of an out of bound stake and since it was in bounds my next shot was to hit it. The stake impeded my shot to the advance the ball. I ended up hitting the ball laterally to the fairway but suffered two strokes as wiffs as I hit the stake twice missing the ball before successfully hitting the ball to the fairway. Not too accurate on the first two shots because of the tightness of the stance and the stake. What options did I have?