What is the optimal swap size
There's an old rule of thumb that says you make this equal to twice the size of your RAM. Here is an article explaining why that's not necessarily the case (any longer). Opinions may vary, but for a typical desktop install, you shouldn't need to go much beyond 2GB. You might need more if you're doing Linux kernel development or planning on using "suspend to disk." But if you are not a very experienced Ubuntu/Linux user, as long as you accepted the value suggested by the installer, you should be ok. But in your case I think the bigger problem is a low amount of RAM (512MB).
is defrag recommended?
The short answer is "it depends," but it is usually not something most Ubuntu users need to concern themselves with. This article "Why doesn't Linux need defragmenting?" does a really good job of explaining this topic.
How much disk space is available on your machine? Edit your post with the results of a
df -k, and we'll take a look. But I suspect that your bigger problem is the half-gig of RAM. I would look at increasing that, if possible.