The alleged attack on the 36-year-old woman took place at 10pm on Friday.
A 32-year-old man has been arrested and charged in connection with the incident, Police Scotland said.
The move came after officers issued an appeal for information.
The man is expected to appear at Selkirk Sheriff Court tomorrow.
Police have issued a reminder for people to ensure their homes are secure at all times.