The Optifine changelog says that OptiFine 1.9.4_HD_U_B5 is compatible with Forge #1937. It can be hard to find in the Optifine installation instructions, but if you put the Optifine jar in the mods folder instead of running it as an installer, it will generally work as a Forge mod (except for versions of Optifine that came out before Forge came out for a given version of Minecraft)
Edit: I just confirmed that OptiFine 1.9.4_HD_U_B5 works with Forge build 1954.
1