。
The medicine worked on his stomach.
Literal
Medicine [topic-は] his stomach [to-に] took-effect-[polite past].
効く with に marks what the medicine is effective against or where it works — 胃に効く ('effective for the stomach'). Polite past 効きました. A straightforward example of medical vocabulary.