detection of absence of 118V DC voltage using optocoupler
If you use the following circuit you'll get a high output voltage is the 118V is absent. Swap transistor and load resistor if you want a low output voltage.  

  

Let's take a look at the CNY17 (though many other optocouplers will do). The CNY17 is available in different CTR (Current Transfer Ratio) classes. CTR tells us how much collector current there will flow in the phototransistor for a given LED current.  

Let's assume a 5V \$V_{CC}\$, that we draw \$200\mu\$A from the output and that the output voltage for a high level should at least be 4V. Then the maximum value for the load resistor should be   


  \$ R = \dfrac{5V - 4V}{200 \mu A} = 5k\Omega \$


Then the collector has to sink 5V/5k\$\Omega\$ = 1mA to drive the output down to 0V.
The CNY17-3 has a CTR of 100-200, that means that for the 1mA out you'll need between 0.5mA and 1mA in. Worst case is 1mA.
Then R1 should be 118V/1mA = 120k\$\Omega\$ (rounded to the nearest E12 value. I'm ignoring the 1.65V across the LED). That's it. 

118V across a resistor is a lot, so let's see if it can handle that. Power = 118V \$\times\$ 1mA = 118mW, so a standard 1/4W PTH resistor is OK. This can also handle the voltage. If you want to use an SMT resistor you'll need at least an 0805.   

The load resistor determines the current, and we can't use a value higher than 5k\$\Omega\$, otherwise the output voltage level will be too low. If that means that you have to drive the LED with a too high current (for instance in an optocoupler with a low CTR, CTRs much lower than 100% are common), you can use a voltage follower to limit the load current, so that you can use a larger resistor value.