Osmolytes are small organic molecules that can modulate the stability and function of cellular proteins by altering the chemical environment of the cell. Some of these osmolytes work in conjunction, via mechanisms that are poorly understood. An example is the naturally occurring protein-protective osmolyte trimethylamine N-oxide (TMAO) that stabilizes cellular proteins in marine organisms against the detrimental denaturing effects of another naturally occurring osmolyte, urea. From a computational standpoint, our understanding of this counteraction mechanism is hampered by the fact that existing force fields fail to capture the correct balance of TMAO and urea interactions in ternary solutions. Using molecular dynamics simulations and Kirkwood-Buff theory of solutions, we have developed an optimized force field that reproduces experimental Kirkwood-Buff integrals. We show through the study of two model systems, a 15-residue polyalanine chain and the R2-fragment (273GKVQIINKKLDL284) of the Tau protein, that TMAO can counteract the denaturing effects of urea by inhibiting protein-urea preferential interaction. The extent to which counteraction can occur is seen to depend heavily on the amino acid composition of the peptide.