Is it ok to mix 2 GB and 4 GB DIMMS in an iMac (mid 2011)?
Yes - it's OK to mix. The more RAM you have, the more files can be cached over time and the more processes can sit resident in RAM for faster switching between tasks running at the same time.

I haven't read the tech note on the latest iMacs, but in general I have never seen a benchmark that shows any mac ever ran slower with more memory. (even the initial intel GMA integrated MacBooks where having non matched RAM where there were only two slots did noticeably slow the graphics performance). The iMacs of the past several years all need high quality ram that matches their specifications fairly exactly - but run well with whatever lineup of good ram is installed.

If it makes a difference, the tech note and consumer installation guide will tell you in which order to install RAM and will call out when matching pairs will make sense due to the architecture of that machine. Again, more ram is always faster.

Also - when you are buying a new mac - often the seller will credit the value of the pre-installed RAM as new memory if you want to buy up to have larger chips (2x4GB) and then you can add the second later as needed.