A man accused of murdering his "on-off" partner had been banned from contacting her weeks before she died, a trial has heard.