There are many factors that go into the true total prject cost for automation. Hardware for the logic is one, and there a PC may be less expensive than a PLC, although many micro-PLCs are available for a few hundred dollars. You need to add I/O to the system, and there the PLC or remote I/O comparison is close to a wash. You need programming software for the PLC, but you need the programming language for the PC as well. Depending on the brand, PLC software can be a few hundred to a few thousand dollars.
You need to add the cost for designing a system. PLCs are well documented, commonly used, and wiring is simple. For a single process or machine you don't need communications with PLCs, but you do for your PC. I always have more trouble wringing out the communications networks on my applications than I do with wiring I/O or with creating logic.
Then you need to add programming cost - i.e. time. Ladder logic is hard to beat here, whether it is in a PLC or a soft PLC running on a PC. This is particularly true when it comes to de-bugging. The PLC software has lots of built in monitoring and de-bugging functions specifically designed to make this process simpler.
You need an operator interface for most applications, for entering tuning and time delays and displaying diagnostics messages. You get the hardware for this "free" with the PC, but you have to program it all. With a PLC system an industrial HMI (Human Machine Interface) often costs more than the PLC, but configuring data entry field, data displays, and messages is usually straightforward and fast, acessing the PLC registers directly in most cases.
You have to take maintenance and service into account. By design PLCs are made to be easy to service, and ladder logic programming can be analyzed and accessed by many people. With a PC using C++ or similar any one other than the original programmer has a tough time servicing the software.
Then there is the cost of downtime - lost production or efficiency when the system fails. An office PC in an industrial environment is doomed to a short life because of vibration, heat, dust, voltage spikes, and so on. PLCs are more rugged and built for the application. You can get industrially hardened PCs, or build protective enclosures for the PC, but by then your cost advantage is gone.
In my opinion, when you take the total life cycle cost of a system PLCs win hands down.