When you turn on the AC, you engage the compressor, which increases the load on the engine. The PCM then commands the IAC to increase the rpms to compensate. This, in turn, maintains engine idle speed, keeps the the charging system going, keeps oil pressure up, etc.
For the P0506 - Idle...