While the first two answers are both fine, you have wealth of resources available *without* spending a fortune on an attorney. If your rental unit is covered by San Francisco's Rent Ordinance, then the first place to go is the City's Rent Board Web site (and you should be aware that many units are covered by the Rent Ordinance's eviction protections, even if they're not protected by rent control):
Go to the "Documents and Resources" section, and get ready to do your homework. It's great stuff for you to know -- San Francisco is very pro-tenant, but it still pays to know your rights and responsibilities.
I presume that you are on the lease, or at least that the landlord knows you live there. If you're on the lease, you are a master tenant, and generally speaking, that does give you the right to evict your subtenant -- for one of the 14 acceptable "just cause" reasons for eviction. If you've lived there for more than 10 years, you do not need just cause to evict a subtenant. If you are not a master tenant then you do not have the right to evict another subtenant. Also, you must follow eviction law just as if you were the landlord. (Basically, the Rent Ordinance does consider master tenants - or original tenants - to be landlords with respect to subtenants.)
If your subtenant is sexually harrassing your other housemate, you might be able to build a just cause eviction case because he is â€œcreating a substantial interference with the comfort, safety or enjoyment of the landlord or other tenants in the building.â€
Additionally, if you have a good relationship with the landlord, it may pay to 'fess up to your illegal subtenant. Depending on the terms of your lease, chances are good that the landlord can evict anyone who moved in without permission, as long as it's done within a reasonable time period from when the landlord learns of the new subtenant.
This can be risky for you since you're supposed to notify the landlord in writing before allowing a subtenant to move in, and if the addition of the subtenant means that you've exceeded the allowable number of occupants, the landlord could initiate eviction proceedings against you. The landlord must give you the opportunity to correct the problem first.
All of this information is available in just a few minutes on the web.
Another great resource is the San Francisco Tenants Union:
Obviously, they're rabidly pro-tenant -- sometimes to a degree that I think gets in the way of human relations (c'mon, can't we all just get along?) But they've dealt with just about every rental situation you can imagine.
If things do get bitter, feel free to contact me for a referral to a lawyer. Hopefully that will be a last resort, and it won't come to that.
And yes, you will be in trouble if you change the lock.
Whatever you do, you DO NOT "pack up his stuff, put it outside the door, change the locks..." That will get you in lots of trouble in San Francisco. (No offense Mike, but Santa Rosa might as well be another planet when it comes to rent law.)
Of course, none of this should be construed as actual legal advice. Just trying to help.