A man has been jailed for at least nine years for subjecting a woman to a terrifying sex attack while he wielded a carving knife in a locked and barricaded NSW house.

Stanley Robin Doolan had earlier threatened the woman's companion, telling him to rape her, before the man managed to escape from the house in Bathurst, in the state's central west, in October 2015.

In setting a maximum term of 12 years in the District Court in Sydney on Tuesday, Judge John Pickering said it was clearly a highly terrifying incident for the 54-year-old woman who was forced at knifepoint to engage in two separate sex acts.

Doolan, 35, had pleaded guilty to aggravated sexual assault and threatening to inflict actual bodily harm on the woman, in addition to using a knife to cause her companion to fear physical harm.

In 2003, Doolan was jailed for at least nine years for aggravated break and enter and aggravated sexual intercourse without consent. He was released on parole in November 2011.