Cain took a ball off his right foot and X-rays showed all was fine, then his right hamstring tightened as he tried to warm up for the seventh inning, shortening his night.
Bochy said Cain would have the injury further evaluated.
Cain missed two weeks last year with the same injury, but he said it's not as bad this time around.
"Last year, it was something that was definitely more on my mind when I did it. I pushed too hard. I thought we were being a lot smarter today," Cain said.
Cain (2-0) pitched six scoreless innings, allowing two hits, striking out three and walking one.
He has been a steady presence in San Francisco's rotation so far.
"We feel like as a staff if we can get some things going in the right direction, we can try to get the momentum on our side," Cain said after the Giants snapped a four-game losing streak with Monday's win.
He beat the Dodgers for the first time since May 5, 2013, also at AT&T Park. The right-hander, a victim of low run support for years and with injury bad luck the past few seasons, had been 0-3 with a 4.86 ERA in six starts since.
Information from The Associated Press was used in this report.