Is HIV infectious if it is outside the body?

Generally not. If the virus remains in human materials like blood, semen, or other body secretions that are not subjected to physical changes which kill the virus it can survive, but outside of these it dies very rapidly upon removal from the body. That is why it takes intimate contact for transmission and does not occur casually.