You need to find a way to remind yourself constantly what you're working on. The best way is to have your editor or IDE do that for you. The IDE can know what you're working on and, through syntax and error highlighting, tell you when you've violated the rules of that language.
If that's not good enough or not available, try some things that will help trick your mind into keeping the information about using the two languages separate. Use different color schemes in your editors to correspond to the language. If possible, code from different workstations or different monitors at the same workstation.
Also, different languages can have different standards for code. For example, Java has very specific recommendations for capitalization of classes, methods, and variables. Make sure you know the standards for each language and use the appropriate standard for each. If you try to make one language look like the other, you'll be much more likely to mix them up in your head.
But, as with everything, the best thing is practice. The more you code in multiple languages at once, the better you'll get at doing it and not mixing them up. But, you're going to do it lots and lots in the process, so don't treat yourself too badly about it.