A method and apparatus for performing device-to-device (D2D) transmission in a wireless communication system is provided. A user equipment (UE) determines that it is out of coverage (OOC). Even though the UE is OOC, the UE continues to perform D2D transmission by using D2D resources for in-coverage under a specific condition. Based on a specific condition, if the UE determines that is in coverage before the specific condition is met, the UE performs D2D transmission by using the D2D resources for in-coverage. If the specific condition is met while the UE is OOC, the UE performs D2D transmission by using the D2D resources for OOC.