Your question is a little hazy, but I think I know what you're asking. I'm going to assume that 1) your OS X machine is connected to a LAN through either a hub or a switch, and the hub is connected via an uplink port to a router, which connects either to DSL or a cable modem. I can't think of a way to keep your Mac connected to the LAN but not the interet, other than disconnecting the entire LAN from the internet. On the other hand, why would you need to? If you turn off file sharing, web serving, ftp and telnet, there's no real reason why you would want to "turn off" the Internet, is there?
If you still feel like your Mac might be vulnerable, you could install a firewall, or learn to configure the BSD firewall which is built into OS X.