This simple circuit will tell you, by sounding a buzzer and flashing a LED, that a telephone line is in use. If the telephone line is free, it will carry a steady direct voltage of something between 48 and 60 volts. This is well above the zener voltage of D5 so optocoupler IC1 is switched on and consequently the oscillator built around IC2 is held disabled. When the line is in use, i.e., a telephone extension is ‘off hook’, the line voltage drops to a level below the zener voltage of D5, and the oscillator is enabled.
LED D6 will flash and buzzer Bz1 will produce intermittent beeps. Note that the buzzer is a DC type. The circuit is best (and most safely) powered by a mains adaptor with an output of 12 Vdc. Since the current consumption is minimal at just 25 mA or so, the smallest adapter you can find will be okay to use. Both optocoupler types indicated in the circuit diagram meet a 5-kV isolation breakthrough specification. The PC123 from Sharp though has ‘bent out’ pins and so meets the isolation distance requirement of 6 mm for equipment connected to the mains, which may well be extended to public telephone systems. The CNY17 does not meet the 6 mm spec and is strictly speaking not safe to use unless you bend out the pins yourself and refrain from using an IC socket.