Yes. Separate the weed killer from the plant by a barrier.   If you use a herbicide that is "contact sprays" as opposed to those with "systemics," it's sufficient to follow those instructions closely about working from the back of the leaf so as not to disturb or harm any sensitive parts of the leaves or flowers.    In addition, some weed killers will have special instructions about how far apart the plants should be sprayed and on produce what can handle exposure.    Follow all instructions carefully and move away from any on-target plants before spraying any off-target weeds near your garden beds.