Make sure the Version of Optifine you've downloaded matches the version of MC you want to use
You need to launch into the desired version of MC at least once to generate necessary install files
Close MC
Go to Downloaded Optifine file (should be a .jar file I believe) and right-click it
Go to "Open With"
Select to Open with Java