expression, godan verb (-ku)
become infested with insects; get worms
Literal sense: insects or worms appear on or in something, such as food, plants, or animals.
古い米に虫が付いた。
The old rice became infested with insects.
expression, godan verb (-ku)
fall in with bad company; get a bad lover
Figurative use: a person (especially a woman) gets involved with an undesirable partner or group. Often used in the negative or as a warning.
You should warn that girl before she falls in with bad company.
彼女に虫が付いたらしい。
It seems she's gotten involved with a bad guy.