'Putting one's hand in one's pocket' is a common phrase that means spending one's own money but only as long as the phrase fits contextually. Also, this phrase doesn't mean you're giving someone something but you're spending something for yourself or others.
Your two sentences...
He put his hand in his pocket and bought it for the guy.
I'll have to put my hand in my pocket to fix my car.
talk about spending something, so they're okay. However, they could use more clarity if they're standalone sentences, such as what did he buy for the guy, or what part of the car needs fixing.