That what male dogs do , they're marking their territory . The first night Marty was here he smelled my winter coat then lift his leg and tried to pee on it and peed on the rug! Marty smelled my last dog who was a male and was marking his territory in the house. Marty does the same outside ,he have to pee on any object that been peed on by another dog. And something Marty will want to taste another dog pee!!
I would let your dog pee a few times before bring back in the house before bed time . Then way he will not have an accident at night.