There are five trains a day from Bergen to Oslo. If you want to spend the day in Bergen then your choice is between a 4pm train and the overnight train which leaves at 11pm. I used the overnight train a couple of years ago because I wanted to maximise time in Bergen (and having travelled up by train I had already seen all the pretty views), but if you want to enjoy the scenery then obviously the earlier train is the one to go for.
As for transport between OSL and Oslo town centre, should you decide to fly: As mentioned before the dedicated airport train is quite expensive, but you can also take an ordinary train (which takes a bit longer because it stops in several places). You can also take an express bus into town.