You need to differentiate if it is your COMPUTER going slow or if it is your internet. Does you computer open programs fine, or is it just the speed of loading pages?
Take a look at your modem when you can't access the Internet - which lights are on?
My advice would be to contact your ISP. This can be a problem with the line, and if that's the case they'll need to send out a technician to fix the problem.