“His passing came as quite a shock to me as I had seen him just an hour before.”
Is this sentence OK?
Instead of ‘before’ can I use ‘ago’?

Yes, it’s OK.

I personally prefer “ago” to be relative to now (the time of speaking), rather than relative to some time in the past.

Of course, you can also say “earlier”, which is perhaps the most common choice.

Right. Generally speaking, I would not use ‘ago’ in a sentence where the past point in time was NOT being measured from the present time.

If the sentence is reported speech, and the word ‘ago’ was part of the original sentence (the direct quote), then the word ‘ago’ (from the direct quote) would generally be changed to something such as ‘before’ or ‘earlier’ in the reported speech version of the sentence.

[size=75]“Sixty years ago I knew everything; now I know nothing; education is a progressive discovery of our own ignorance.” ~ Will Durant[/size]