I think the best way to avoid the situation is to anyhow let him know that you are engaged with someone else. It could help as people use to flirt where they finds a scope, in most of the cases. So, when scope is low, the incidence of flirt would also go down. This way, you will not loose your job and could also escape from the flirty boss easily.