First, you have to post a pic
Second, it just takes lots of patience. The best you can do is let him out every 30 minutes, after playing, napping, eating, drinking. When he pees or poops outside, praise! Show him how happy you are (treats work too). Rince and repeat.
If he pees inside, if you see him, say a firm no, and take him outside. It doesn't really matter if he pees or not once outside, if he does, praise, if not just take him back in, but it will show him where he's supposed to pee. If you don't see him pee but you find the puddle, just clean it. Cleaning carpet is a pain though, and most products don't get rid of the smell totally (especially not for dogs), so if there is still a smell, he will naturally go back there to pee. So the best is to buy some nature's miracle, which is a product that gets rid of the smell even for dogs, and soak the carpet with it everytime he pees, to get rid of the smell.
Dogs are usually half housebroken at this age, but if he hasn't got any training it will take a while, but he should get it. It's easier after 4 months because they have a better control of their bladder, but it can take a few months.
Just keep in mind that patience is key, and lots of praise when he pees outside, so that he will want to do it again.