Some small dogs can be very hard to house train. Is he neutered?
It would be your decision to try and rehome him but new owners may not be so patient.
I suggest you check into belly bands. Do a Google search. Many people I know use these on their small and large dogs inside the house.
Is the dog alone for long periods of time (while you are at work, say)? That could be the driving issue and the only fix I can' think of is to limit where the dog can go when you are away.
Or, does the dog carry on in your presence - in front of you? If you can catch the dog in the act you have a better chance of changing the behavior.
If the dog is alone for long periods it may be a good idea to try to find the dog a home where someone is home a good part of the day and at night. better if they have a fenced yard.
Hope you get better help from others here, thankfully I have never had that problem with our dogs.