It is a good idea to file it with the court right after you file the case. You don't want the to be forced into using the homestead exemption if you want the wildcard exemption (which is what will happen if you fail to file the spousal waiver). I have brought the waiver to the hearing in the past and filed it after the hearing but I don't recommend it. Best just to file it after you file the case so the Trustee sees it in the docket when he reviews prior to the 341 hearing. Good luck with that and contact a bankruptcy attorney if you have a problem filing it.
You may need to provide more information in order to receive an accurate response. In Arizona, where I practice, if only one spouse is filing a bankruptcy case, there is no spousal waiver that must be filed, however in most circumstances the non-filing spouse's income and community assets must be disclosed in the filing spouse's statements and schedules.