Many attorneys will advise their clients to change the locks, alter the garage door opener, and change the alarm system code in conjunction with the filing of a divorce suit. If you fear that your spouse will return to the residence for the purpose of creating havoc, causing injury or other malicious purpose, the exclusion of that person from the house is probably an appropriate method to thwart the misbehavior. Usually, the changing of locks, etc. should be coordinated with the filing of the divorce suit and service of the divorce paperwork upon the other party.
You should consider your options before making such a decision. If you believe your spouse will agree to move out after learning you have filed a divorce suit, changing the locks may be an unnecessary expense.