It could be a few things. He may be afraid to get up in the middle of the night in the dark and go to the bathroom alone. If this is the case, putting a potty chair in his room may give him an alternate place to go.
It could also be that he is not fully awake and thinks he is in the bathroom. This is VERY common with boys. One of my brothers used to get up and night and pee in the hall closet next to the bathroom because he thought it was the bathroom. All of my brothers at some point or another peed on the bathroom wall next to the toilet thinking they were aiming in the right direction.
You could use a baby monitor to hear when he gets up at night so you can go help him, or you can try getting him to call for you. I'd bet it's that he's not fully awake and in that case is not something he can help. He will grow out of it, but in the meantime, I suggest trying all three things.