This is a great question, as so many players make mistakes when value betting.
First of all, let’s separate value betting on the river from the other streets.
Value betting on the flop and turn has to take into consideration the future streets, which complicates the mathematics and makes a simple formula less useful.
On the river, however, there is a process I find useful.
Count the number of hands in your opponent’s continuance range that you are beating (this is not his entire range, but the range with which he is going to flat-call or raise your bet). Next, count the number of hands in his calling and raising range that have you beaten. Which category has more hands in it?
If it is clearly category 1, then you should normally be value betting. If it is clearly category 2, then you should not be value betting.
This is about as close to a formula as you can get.
Top Tip: Try and learn to think in combinations. Using Flopzilla or another range tool can help with this
You also need to consider your position. If you are out of position, sometimes check-calling can be smarter if there are lots of hands your opponent will bluff with. So, even if value betting has positive expectation, check-calling might make more money.
Okay, so far so good?
If you are considering value betting on the flop or turn, you also need to think about the future streets and how things are likely to play out.
This makes life really tough. In general, if you consider your range to be stronger than your opponent’s range, value betting is often the right strategy.
Nevertheless, marginal hands such as one pair hands need to be played carefully, so you are not building huge pots, especially if out of position.
A final thing to consider is your opponent and how fishy he is. It is easier to get value from weak opponents, so you can value bet more often. You can also choose larger bet sizes!
Bet sizing is another important consideration. Try and divide your opponent's hands into categories and think about how he will behave with different hand types against different bet sizes.
Remember too that you are not just playing your specific hand. Try and make sure your bet size choice is logical both as a value bet and also as a bluff, so you present a genuine problem to your opponent.