Steve Stannard, 37, died after being stabbed at his flat at Bowers Avenue in Norwich on 5 November 2016.
Norwich Crown Court heard a knife found nearby had his blood on it.
Hassiem Baqir, 19, of Howberry Road, Thornton Heath, south London, denies murder.
Andrew Shaw, prosecuting, said a sample of DNA taken from the handle of the knife matched Mr Baqir.
Mr Shaw said Mr Stannard was a drug user and low level drug dealer who had allowed his home to be used as a base by Mr Baqir to sell drugs in Norwich.
He told the court another user went to the property and saw Mr Baqir with the knife. When she asked why he had it, he replied: "It's not a game, it's just in case."
The court heard Mr Stannard was stabbed twice in the back and three times in the front at his home. The wounds perforated his lung and his heart.
Mr Stannard's dog, a border collie called Trixy, was also stabbed - probably defending her master, Mr Shaw said.
Mr Baqir has admitted supplying heroin and cocaine
He is on trial with two other men, Veron Antonio, 24, of Green Lane, Morden, south London, who has denied supplying heroin and cocaine and assisting an offender by failing to comply with an order to reveal his phone PIN code to police.
A third person, Jamil Theo Carrol, 28, of no fixed address, denies assisting an offender.
The trial continues.
DNA found on the handle of a knife after a man was stabbed to death matches that of the man accused of his murder, a court has heard.