When you are outside with your your yorkie, praise him when he pees or poops.
Give him some type of treat as a reward.
Let him know that outside is the place to go.
When you are inside and you catch your yorkie in the act of relieving himself, say a firm "No!" and immediately take him outside.